### Setup Environment Source: https://docs.liquid.ai/examples/customize-models/home-assistant Clone the repository, install dependencies, and authenticate with HuggingFace and Modal. ```bash git clone https://github.com/Liquid4All/leap-finetune cd leap-finetune && uv sync && cd - huggingface-cli login modal setup ``` -------------------------------- ### Clone Repository and Navigate Source: https://docs.liquid.ai/examples/android/leap-koog-agent Clone the example repository and navigate to the LeapKoogAgent directory to begin setup. ```bash git clone https://github.com/Liquid4All/LeapSDK-Examples.git cd LeapSDK-Examples/Android/LeapKoogAgent ``` -------------------------------- ### Setup Python environment Source: https://docs.liquid.ai/examples/laptop-examples/audio-car-cockpit Clones the repository and installs necessary dependencies for the audio car cockpit demo. ```bash git clone https://github.com/Liquid4All/cookbook.git cd cookbook/examples/audio-car-cockpit make setup ``` -------------------------------- ### Install and Authenticate Environment Source: https://docs.liquid.ai/examples/customize-models/satellite-vlm Initial setup for the project environment, including dependency synchronization, Modal authentication, and Hugging Face login. ```bash uv sync uv run python -m modal setup uv run huggingface-cli login ``` -------------------------------- ### Complete Tool Use Example Setup Source: https://docs.liquid.ai/lfm/key-concepts/tool-use Initializes the model and tokenizer, defines tools using JSON, and sets up the conversation messages for tool use. ```python import json from transformers import AutoModelForCausalLM, AutoTokenizer model = AutoModelForCausalLM.from_pretrained( "LiquidAI/LFM2.5-1.2B-Instruct", dtype="bfloat16", device_map="auto" ) tokenizer = AutoTokenizer.from_pretrained("LiquidAI/LFM2.5-1.2B-Instruct") tools = [{ "name": "get_candidate_status", "description": "Retrieves the current status of a candidate in the recruitment process", "parameters": { "type": "object", "properties": { "candidate_id": { "type": "string", "description": "Unique identifier for the candidate", } }, "required": ["candidate_id"], }, }] messages = [ {"role": "system", "content": f"List of tools: {json.dumps(tools)}"}, {"role": "user", "content": "What is the current status of candidate ID 12345?"}, ] ``` -------------------------------- ### Install, Launch, and Query Sglang Source: https://docs.liquid.ai/lfm/models/lfm2-350m Setup for Sglang server and querying via the OpenAI-compatible API. ```bash uv pip install "sglang>=0.5.10" ``` ```bash (toolCallParser ? `sglang serve \ --model-path ${modelId} \ --host 0.0.0.0 \ --port 30000 \ --tool-call-parser ${toolCallParser}` : `sglang serve \ --model-path ${modelId} \ --host 0.0.0.0 \ --port 30000`) ``` ```python from openai import OpenAI client = OpenAI(base_url="http://localhost:30000/v1", api_key="None") response = client.chat.completions.create( model="${modelId}", messages=[{"role": "user", "content": "What is machine learning?"}], temperature=0.3, ) print(response.choices[0].message.content) ``` -------------------------------- ### Clone Repository and Setup Environment Source: https://docs.liquid.ai/examples/customize-models/car-maker-identification Clones the Liquid AI cookbook repository, navigates into the example directory, and synchronizes Python dependencies using uv. ```bash git clone https://github.com/Liquid4All/cookbook.git cd cookbook/examples/car-maker-identification uv sync ``` -------------------------------- ### Complete Custom Model Bundling Workflow Source: https://docs.liquid.ai/deployment/tools/model-bundling/quick-start This example demonstrates the complete workflow for bundling custom models, including installation, authentication, bundle creation, monitoring, and downloading. ```sh pip install leap-bundle leap-bundle login leap-bundle whoami leap-bundle create leap-bundle list leap-bundle download ``` -------------------------------- ### Install Dependencies Source: https://docs.liquid.ai/examples/laptop-examples/lfm2-english-to-korean Install the project's dependencies using the 'uv sync' command. Ensure you have uv installed. ```bash uv sync ``` -------------------------------- ### Clone and Navigate to Example Repository Source: https://docs.liquid.ai/examples/android/vision-language-model-example Initial commands to retrieve the VLM example project from GitHub. ```bash git clone https://github.com/Liquid4All/LeapSDK-Examples.git cd LeapSDK-Examples/Android/VLMExample ``` -------------------------------- ### Install and Run vLLM for LFM2-24B-A2B Source: https://docs.liquid.ai/lfm/models/lfm2-24b-a2b Install vLLM using pip. Then, load the model and run inference with specified sampling parameters. This example demonstrates a basic chat interaction. ```bash pip install vllm==0.14 ``` ```python from vllm import LLM, SamplingParams llm = LLM(model="${modelId}") sampling_params = SamplingParams(${samplingParams}max_tokens=512) output = llm.chat("What is machine learning?", sampling_params) print(output[0].outputs[0].text) ``` -------------------------------- ### SGLang Quick Start Source: https://docs.liquid.ai/lfm/models/lfm2-350m This example shows how to use SGLang to interact with the LFM2-350M model. SGLang provides a Pythonic interface for defining and executing language model workloads. ```python from lang import: app = Lang<"LiquidAI/LFM2-350M"> response = app.chat( [ {"role": "user", "content": "Project: /websites/liquid_ai\nContent:\n [{"role": "user", "content": "What is machine learning?"}],"} ] ) print(response) ``` -------------------------------- ### Run Hand & Voice Racer locally Source: https://docs.liquid.ai/examples/web/hand-voice-racer Commands to install dependencies and start the development server for the project. ```bash npm install npm run dev ``` -------------------------------- ### Launch the demo Source: https://docs.liquid.ai/examples/laptop-examples/audio-car-cockpit Starts the audio server and the web interface concurrently. ```bash make -j2 audioserver serve ``` -------------------------------- ### llama.cpp Quick Start Source: https://docs.liquid.ai/lfm/models/lfm2-350m Integrate the LFM2-350M model with llama.cpp for efficient inference. This example shows how to set sampling parameters for text generation. ```bash ./main -m LiquidAI/LFM2-350M-GGUF --temp 0.3 --min-p 0.15 --repeat-penalty 1.05 -p "Project: /websites/liquid_ai\nContent:\n [{"role": "user", "content": "What is machine learning?"}]," ``` -------------------------------- ### Install Dependencies Source: https://docs.liquid.ai/examples/web/audio-webgpu-demo Install the required project dependencies. ```bash npm install ``` -------------------------------- ### Install Dependencies and Push Model Source: https://docs.liquid.ai/deployment/gpu-inference/baseten Navigate to the cloned directory and install dependencies, then push the LFM2-8B model to Baseten. ```bash cd bastenpip install trusstruss push lfm2-8b --publish ``` -------------------------------- ### Install liquid-audio Source: https://docs.liquid.ai/lfm/models/lfm2-audio-1.5b Install the liquid-audio library and optional dependencies for demos and flash attention. ```bash pip install liquid-audio ``` ```bash pip install "liquid-audio[demo]" # optional, for demo dependencies ``` ```bash pip install flash-attn --no-build-isolation # optional, for flash attention 2 ``` -------------------------------- ### LEAP Bundle CLI usage examples Source: https://docs.liquid.ai/deployment/tools/model-bundling/bundle-creation Various examples for creating bundles, including standard, JSON-formatted, and quantized output. ```sh # Create bundle from directory leap-bundle create ./my-model-directory # Example output on success ℹ Calculating directory hash... ℹ Submitting bundle request... ✓ Bundle request created with ID: 18734 ℹ Starting upload... Uploading directory... ✓ ✓ Upload completed successfully! Request ID: 18734 # Example output when request already exists ⚠ A bundle request with the same input hash already exists: req_xyz789abc123 # Create bundle with JSON output leap-bundle create ./my-model-directory --json # Example JSON output on success {"request_id": "18734", "status": "success"} # Example JSON output when request already exists {"error": "A bundle request with the same input hash already exists: req_xyz789abc123", "status": "exists"} # Create GGUF bundle with specific quantization leap-bundle create ./my-model-directory --quantization Q8_0 ``` -------------------------------- ### Install vLLM Source: https://docs.liquid.ai/deployment/gpu-inference/vllm Commands to install vLLM or pull the prebuilt Docker image. ```bash uv pip install vllm==0.14 ``` ```bash docker pull vllm/vllm-openai:latest ``` -------------------------------- ### Install Weights & Biases Source: https://docs.liquid.ai/examples/customize-models/car-maker-identification Installs the Weights & Biases Python package using uv. Ensure you have uv installed and are within your virtual environment. ```bash uv add wandb ``` -------------------------------- ### Install and Run Transformers Source: https://docs.liquid.ai/lfm/models/lfm2-350m Installation and model loading using the Hugging Face Transformers library. ```bash pip install "transformers>=5.2.0" torch accelerate ``` ```python from transformers import AutoModelForCausalLM, AutoTokenizer model_id = "${modelId}" model = AutoModelForCausalLM.from_pretrained( model_id, device_map="auto", dtype="bfloat16", ) tokenizer = AutoTokenizer.from_pretrained(model_id) inputs = tokenizer.apply_chat_template( ``` -------------------------------- ### Install Transformers and PyTorch Source: https://docs.liquid.ai/lfm/help/contributing Install the necessary libraries for working with transformer models. ```bash pip install transformers torch ``` -------------------------------- ### Clone and build the project Source: https://docs.liquid.ai/examples/laptop-examples/flight-search-assistant Clone the repository and install the necessary project dependencies. ```bash git clone https://github.com/Liquid4All/cookbook.git cd cookbook/examples/flight-search-assistant uv sync ``` -------------------------------- ### Complete Model Download Management Example Source: https://docs.liquid.ai/deployment/on-device/android/ai-agent-usage-guide A comprehensive ViewModel example demonstrating how to check model status, download models if needed, manage storage, remove models, and cancel downloads. It integrates storage checks and provides user feedback via StateFlow. ```kotlin class ModelManagementViewModel(application: Application) : AndroidViewModel(application) { private val downloader = LeapModelDownloader(application) private val _downloadStatus = MutableStateFlow(ModelDownloadStatus.NotOnLocal) val downloadStatus: StateFlow = _downloadStatus.asStateFlow() private val _errorMessage = MutableStateFlow(null) val errorMessage: StateFlow = _errorMessage.asStateFlow() // Check if model is already downloaded suspend fun checkModelStatus(modelSlug: String, quantizationSlug: String) { val status = downloader.queryStatus(modelSlug, quantizationSlug) _downloadStatus.value = status } // Download model if not cached fun downloadIfNeeded(modelSlug: String, quantizationSlug: String) { viewModelScope.launch { try { val status = downloader.queryStatus(modelSlug, quantizationSlug) if (status is ModelDownloadStatus.Downloaded) { Log.d(TAG, "Model already downloaded") return@launch } // Check storage before downloading if (getAvailableStorageGB() < 2) { _errorMessage.value = "Insufficient storage space" return@launch } // Start download downloader.downloadModel( modelSlug = modelSlug, quantizationSlug = quantizationSlug, progress = { progressData -> _downloadStatus.value = ModelDownloadStatus.DownloadInProgress( progress = progressData.progress ) } ) _downloadStatus.value = ModelDownloadStatus.Downloaded } catch (e: Exception) { _errorMessage.value = "Download failed: ${e.message}" Log.e(TAG, "Download error", e) } } } // Remove model to free up space fun removeModel(modelSlug: String, quantizationSlug: String) { viewModelScope.launch { try { downloader.removeModel(modelSlug, quantizationSlug) _downloadStatus.value = ModelDownloadStatus.NotOnLocal Log.d(TAG, "Model removed") } catch (e: Exception) { _errorMessage.value = "Failed to remove model: ${e.message}" } } } // Cancel download fun cancelDownload(modelSlug: String, quantizationSlug: String) { downloader.cancelDownload(modelSlug, quantizationSlug) _downloadStatus.value = ModelDownloadStatus.NotOnLocal } private fun getAvailableStorageGB(): Long { val path = Environment.getDataDirectory() val stat = StatFs(path.path) val availableBytes = stat.availableBlocksLong * stat.blockSizeLong return availableBytes / (1024 * 1024 * 1024) } companion object { private const val TAG = "ModelManagement" } } ``` -------------------------------- ### Install make utility Source: https://docs.liquid.ai/examples/customize-models/car-maker-identification Installs the make utility on Debian-based systems using apt-get. This is a common build automation tool. ```bash sudo apt-get install make ``` -------------------------------- ### Launch SGLang Server Source: https://docs.liquid.ai/lfm/models/lfm25-1.2b-base Start the SGLang server to host the model. ```bash sglang serve \ --model-path LiquidAI/LFM2.5-1.2B-Base \ --host 0.0.0.0 \ --port 30000 ``` -------------------------------- ### Install PyLate Source: https://docs.liquid.ai/lfm/models/lfm2-colbert-350m Install the PyLate library using pip. This is the first step before using the LFM2-ColBERT-350M model for inference. ```bash pip install -U pylate ``` -------------------------------- ### Deploy vLLM Server Source: https://docs.liquid.ai/deployment/gpu-inference/vllm Methods for starting an OpenAI-compatible vLLM server. ```bash vllm serve LiquidAI/LFM2.5-1.2B-Instruct \ --host 0.0.0.0 \ --port 8000 \ --dtype auto ``` ```bash docker run --runtime nvidia --gpus all \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=$HF_TOKEN" \ -p 8000:8000 \ --ipc=host \ vllm/vllm-openai:latest \ --model LiquidAI/LFM2.5-1.2B-Instruct ``` -------------------------------- ### Load Local Model Examples Source: https://docs.liquid.ai/deployment/on-device/ios/model-loading Provides examples for loading local models using the `Leap.load` function. One example demonstrates loading an ExecuTorch backend via a `.bundle` file, and the other loads a llama.cpp backend via a `.gguf` file. ```swift // ExecuTorch backend via .bundle let bundleURL = Bundle.main.url(forResource: "qwen3-0_6b", withExtension: "bundle")! let runner = try await Leap.load(url: bundleURL) // llama.cpp backend via .gguf let ggufURL = Bundle.main.url(forResource: "qwen3-0_6b", withExtension: "gguf")! let ggufRunner = try await Leap.load(url: ggufURL) ``` -------------------------------- ### Install Modal Source: https://docs.liquid.ai/examples/customize-models/home-assistant Add the Modal package to your project and authenticate your environment. ```bash uv add modal ``` ```bash uv run modal setup ``` -------------------------------- ### Resume bundle request examples Source: https://docs.liquid.ai/deployment/tools/model-bundling/bundle-creation Examples of resuming uploads, including using specific IDs and JSON output format. ```sh # Resume the latest failed upload leap-bundle resume # Example output on success ℹ Retrieving latest bundle request... ✓ Resuming upload for request 18734... ℹ Input path: /path/to/model/directory ℹ Using parallel upload with multipart support... ✓ Upload completed successfully! Request ID: 18734 # Resume a specific request by ID leap-bundle resume 18734 # Example output ℹ Retrieving bundle request 18734... ✓ Resuming upload for request 18734... ℹ Input path: /path/to/model/directory ℹ Using parallel upload with multipart support... ✓ Upload completed successfully! Request ID: 18734 # Resume with JSON output leap-bundle resume 18734 --json # Example JSON output on success {"request_id": "18734", "status": "success"} ``` -------------------------------- ### Install Transformers dependencies Source: https://docs.liquid.ai/deployment/gpu-inference/transformers Install the necessary packages including transformers, torch, and accelerate using uv. ```bash uv pip install "transformers>=5.2.0" torch accelerate ``` -------------------------------- ### Install TRL and dependencies Source: https://docs.liquid.ai/customization/finetuning-frameworks/trl Install the core TRL library along with necessary dependencies for LoRA support and distributed training. ```bash pip install trl>=0.9.0 transformers>=4.55.0 torch>=2.6 peft accelerate ``` -------------------------------- ### Few-shot Prompting Example Source: https://docs.liquid.ai/lfm/key-concepts/text-generation-and-prompting Provide example interactions to guide the model's behavior. The model learns from the conversation history and applies patterns to new inputs. ```python messages = [ {"role": "system", "content": "You are a helpful assistant that formats dates."}, {"role": "user", "content": "2024-01-15"}, {"role": "assistant", "content": "January 15, 2024"}, {"role": "user", "content": "2024-12-25"}, {"role": "assistant", "content": "December 25, 2024"}, {"role": "user", "content": "2024-03-08"} # Model follows the pattern ] ``` -------------------------------- ### Install leap-bundle CLI Source: https://docs.liquid.ai/deployment/tools/model-bundling/quick-start Install the Liquid Edge AI Platform (LEAP) model bundling tool using pip. Ensure you have Python 3.8 or higher. ```bash pip install leap-bundle ``` -------------------------------- ### Install and Run llama.cpp for LFM2-24B-A2B Source: https://docs.liquid.ai/lfm/models/lfm2-24b-a2b Install llama.cpp using Homebrew. Then, run the model using llama-cli, specifying the GGUF repository and context size. The -hf flag downloads the model from Hugging Face. ```bash brew install llama.cpp ``` ```bash llama-cli -hf ${ggufRepo} -c 4096 --color -i \ ${samplingFlags} ``` -------------------------------- ### Install Weights & Biases Source: https://docs.liquid.ai/examples/customize-models/home-assistant Add the wandb package to your project and authenticate your account. ```bash uv add wandb ``` ```bash uv run wandb login ``` -------------------------------- ### Clone and Navigate to Repository Source: https://docs.liquid.ai/examples/android/recipe-generator-constrained-output Commands to clone the example repository and enter the project directory. ```bash git clone https://github.com/Liquid4All/LeapSDK-Examples.git cd LeapSDK-Examples/Android/RecipeGenerator ``` -------------------------------- ### Clone and Setup Repository Source: https://docs.liquid.ai/examples/web/audio-webgpu-demo Commands to clone the cookbook repository and navigate to the audio-webgpu-demo directory. ```bash git clone https://github.com/Liquid4All/cookbook.git cd cookbook/examples/audio-webgpu-demo ``` -------------------------------- ### Prefill for Structured Output Source: https://docs.liquid.ai/lfm/key-concepts/text-generation-and-prompting Start the model with a specific format or structure, such as a JSON opening brace, to guide it toward structured outputs. ```python messages = [ {"role": "system", "content": "Extract information and return as JSON."}, {"role": "user", "content": "Extract the name and age from: John is 30 years old."}, {"role": "assistant", "content": "{\n \"name\": "} # Prefill with JSON structure ``` -------------------------------- ### Start Development Server Source: https://docs.liquid.ai/examples/web/audio-webgpu-demo Launch the local development server to run the application. ```bash npm run dev ``` -------------------------------- ### Install LiquidONNX Source: https://docs.liquid.ai/deployment/on-device/onnx Clone the repository and set up the environment using uv. Use the gpu extra for hardware-accelerated inference. ```bash git clone https://github.com/Liquid4All/onnx-export.git cd onnx-export uv sync # For GPU inference uv sync --extra gpu ``` -------------------------------- ### Prepare models Source: https://docs.liquid.ai/examples/laptop-examples/audio-car-cockpit Downloads the required audio and tool-calling models for the demo. ```bash make LFM2.5-Audio-1.5B-GGUF LFM2-1.2B-Tool-GGUF ``` -------------------------------- ### Multi-turn Conversation Prompting Source: https://docs.liquid.ai/lfm/key-concepts/text-generation-and-prompting Continue a conversation or provide example interactions to guide the model. The model learns from the conversation history and applies patterns to new inputs. ```python messages = [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What are the benefits of exercise?"}, {"role": "assistant", "content": "Exercise has many benefits including:\n1. Improved cardiovascular health\n2. "}, # Partial response to continue {"role": "user", "content": "Tell me more about cardiovascular health."} ``` -------------------------------- ### Clone and prepare the repository Source: https://docs.liquid.ai/examples/laptop-examples/invoice-extractor-tool-with-liquid-nanos Download the cookbook repository and navigate to the invoice parser example directory. ```sh git clone https://github.com/Liquid4All/cookbook.git cd cookbook/examples/invoice-parser ``` -------------------------------- ### Run LFM2-VL-1.6B with Transformers Source: https://docs.liquid.ai/lfm/models/lfm2-vl-1.6b Load and run the LFM2-VL-1.6B model using the Hugging Face Transformers library. This example demonstrates loading the model and processor, processing an image from a URL, and generating a response to a text query about the image. Ensure you have the necessary libraries installed. ```python from transformers import AutoProcessor, AutoModelForImageTextToText from transformers.image_utils import load_image model_id = "LiquidAI/LFM2-VL-1.6B" model = AutoModelForImageTextToText.from_pretrained( model_id, device_map="auto", dtype="bfloat16", ) processor = AutoProcessor.from_pretrained(model_id) url = "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" image = load_image(url) conversation = [ { "role": "user", "content": [ {"type": "image", "image": image}, {"type": "text", "text": "What is in this image?"}, ], }, ] inputs = processor.apply_chat_template( conversation, add_generation_prompt=True, return_tensors="pt", return_dict=True, tokenize=True, ).to(model.device) outputs = model.generate(**inputs, do_sample=True, temperature=0.1, min_p=0.15, repetition_penalty=1.05, max_new_tokens=256) response = processor.batch_decode(outputs, skip_special_tokens=True)[0] print(response) ``` -------------------------------- ### Start the application server Source: https://docs.liquid.ai/examples/customize-models/home-assistant Launch the Uvicorn server to run the application locally. ```bash uv run uvicorn app.server:app --port 5173 --reload ``` -------------------------------- ### Clone the repository Source: https://docs.liquid.ai/examples/customize-models/home-assistant Download the cookbook repository to access the home assistant example files. ```bash git clone https://github.com/Liquid4All/cookbook.git cd cookbook/examples/home-assistant ``` -------------------------------- ### Install uv on macOS/Linux Source: https://docs.liquid.ai/examples/laptop-examples/meeting-summarization Installs the uv package manager using a curl command. Ensure you have curl installed. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### Install Ollama on Linux Source: https://docs.liquid.ai/deployment/on-device/ollama Use this command to install Ollama on Linux systems by downloading and executing the official installation script. ```bash curl -fsSL https://ollama.com/install.sh | sh ``` -------------------------------- ### Install llama.cpp via Homebrew Source: https://docs.liquid.ai/deployment/on-device/llama-cpp Use this command to install llama.cpp on macOS or Linux systems that have Homebrew package manager installed. ```bash brew install llama.cpp ``` -------------------------------- ### Install uv on Windows Source: https://docs.liquid.ai/examples/laptop-examples/meeting-summarization Installs the uv package manager using a PowerShell command. This command bypasses execution policy restrictions for installation. ```powershell powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" ``` -------------------------------- ### Preview Documentation Locally Source: https://docs.liquid.ai/lfm/help/contributing Use the mintlify CLI to preview your documentation changes locally before submitting them. ```bash mintlify dev ``` -------------------------------- ### List Installed Models Source: https://docs.liquid.ai/deployment/on-device/ollama View all models currently installed with Ollama. ```bash ollama list ``` -------------------------------- ### Basic Usage Source: https://docs.liquid.ai/deployment/on-device/android/utilities Demonstrates the fundamental steps to initialize the LeapModelDownloader and download a model. ```APIDOC ## Basic Usage This section shows how to initialize the `LeapModelDownloader` and start downloading a model. ### Initialization ```kotlin import ai.liquid.leap.model_downloader.LeapModelDownloader import ai.liquid.leap.model_downloader.LeapModelDownloaderNotificationConfig // Initialize (in onCreate or similar) val modelDownloader = LeapModelDownloader( context, notificationConfig = LeapModelDownloaderNotificationConfig.build { notificationTitleDownloading = "Downloading AI model..." notificationTitleDownloaded = "Model ready!" notificationContentDownloading = "Please wait..." } ) ``` ### Download and Load Model ```kotlin import android.util.Log import androidx.lifecycle.lifecycleScope import kotlinx.coroutines.launch lifecycleScope.launch { try { val modelRunner = modelDownloader.loadModel( modelSlug = "LFM2-1.2B", quantizationSlug = "Q5_K_M", progress = { progressData -> Log.d(TAG, "Progress: ${progressData.progress * 100}%") } ) // Model is ready to use } catch (e: Exception) { Log.e(TAG, "Failed to load model: ${e.message}") } } ``` ``` -------------------------------- ### Install uv Source: https://docs.liquid.ai/examples/customize-models/home-assistant Install the uv package manager for managing Python dependencies. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` ```powershell powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" ``` -------------------------------- ### Start llama-server Source: https://docs.liquid.ai/deployment/on-device/llama-cpp Launch the OpenAI-compatible server using either a remote Hugging Face ID or a local file path. ```bash llama-server -hf LiquidAI/LFM2.5-1.2B-Instruct-GGUF -c 4096 --port 8080 ``` ```bash llama-server -m lfm2.5-1.2b-instruct-q4_k_m.gguf -c 4096 --port 8080 ``` -------------------------------- ### Verify uv installation Source: https://docs.liquid.ai/examples/laptop-examples/flight-search-assistant Check that the uv package manager is installed on your system. ```bash uv --version ``` -------------------------------- ### Start Vision Model Server Source: https://docs.liquid.ai/docs/inference/llama-cpp Launch a local server to host the vision model for API access. ```bash llama-server \ -m LFM2-VL-1.6B-Q8_0.gguf \ --mmproj mmproj-LFM2-VL-1.6B-Q8_0.gguf \ -c 4096 \ --port 8080 \ -ngl 99 ``` -------------------------------- ### Install Transformers.js Source: https://docs.liquid.ai/deployment/on-device/onnx Install the required package for running ONNX models in the browser. ```bash npm install @huggingface/transformers ``` -------------------------------- ### Verify npm Installation Source: https://docs.liquid.ai/examples/web/audio-webgpu-demo Check the installed version of npm to ensure the environment is ready. ```bash npm --version ``` -------------------------------- ### Deploy and Register Model Source: https://docs.liquid.ai/examples/customize-models/home-assistant Start the local server and register custom models in the server configuration. ```bash uv run uvicorn app.server:app --port 5173 --reload ``` ```bash open http://localhost:5173 ``` -------------------------------- ### Run liquid-audio Gradio Demo Source: https://docs.liquid.ai/lfm/models/lfm2-audio-1.5b Start the Gradio web server for the liquid-audio demo. The server will be accessible at http://localhost:7860/. ```bash liquid-audio-demo # Starts webserver on http://localhost:7860/ ``` -------------------------------- ### Example Analysis Output Source: https://docs.liquid.ai/examples/android/vision-language-model-example This is an example of the AI-generated analysis output for an image of a sunset over a beach. ```text "The image shows a beautiful sunset scene at a beach. The sky displays vibrant orange and pink hues as the sun sets on the horizon. The ocean water reflects the warm colors of the sky. In the foreground, there are silhouettes of people walking along the shoreline. The overall mood is peaceful and serene." ``` -------------------------------- ### Clone the SloganApp Repository Source: https://docs.liquid.ai/examples/android/slogan-generator Use Git to clone the example repository and navigate to the SloganApp directory. ```bash git clone https://github.com/Liquid4All/LeapSDK-Examples.git cd LeapSDK-Examples/Android/SloganApp ``` -------------------------------- ### Validate a model directory example Source: https://docs.liquid.ai/deployment/tools/model-bundling/bundle-creation Example usage and output for validating a model directory. ```sh # Validate a model directory leap-bundle validate ./my-model-directory # Example output on success ✓ Directory validation passed ✓ Directory is ready for bundle creation # Example output on failure ✗ Validation failed: No config.json found in directory. ``` -------------------------------- ### Install sglang Source: https://docs.liquid.ai/lfm/models/lfm2-2.6b-transcript Install sglang using pip. Ensure you have a version greater than or equal to 0.5.10. ```bash uv pip install "sglang>=0.5.10" ``` -------------------------------- ### Verify llama.cpp installation Source: https://docs.liquid.ai/examples/customize-models/home-assistant Confirm that the llama-server binary is correctly installed and accessible on your system PATH. ```bash llama-server --version ``` -------------------------------- ### Build for Production Source: https://docs.liquid.ai/examples/web/audio-webgpu-demo Create an optimized production build in the dist directory. ```bash npm run build ``` -------------------------------- ### Install MLX language model package Source: https://docs.liquid.ai/deployment/on-device/mlx Install the necessary library to interface with MLX models. ```bash pip install mlx-lm ``` -------------------------------- ### MDX Page Structure Example Source: https://docs.liquid.ai/lfm/help/contributing An example of the frontmatter and basic structure for an MDX documentation page. ```mdx --- title: "Page Title" description: "Brief description for SEO and previews (1-2 sentences)" --- Introduction paragraph explaining what this page covers. ## Main Section Content organized under clear headings... ### Subsection More detailed content... ## Next Steps Brief description ``` -------------------------------- ### Start llama-server with Hugging Face model Source: https://docs.liquid.ai/docs/inference/llama-cpp Launches the llama.cpp server, automatically downloading the specified model from Hugging Face. Ensure the model ID is correct. ```bash llama-server -hf LiquidAI/LFM2.5-1.2B-Instruct-GGUF -c 4096 --port 8080 ``` -------------------------------- ### Start llama-server with local GGUF model Source: https://docs.liquid.ai/docs/inference/llama-cpp Launches the llama.cpp server using a pre-downloaded GGUF model file. Specify the correct path to your model. ```bash llama-server -m lfm2.5-1.2b-instruct-q4_k_m.gguf -c 4096 --port 8080 ``` -------------------------------- ### Example Function Definition Source: https://docs.liquid.ai/deployment/on-device/ios/function-calling A comprehensive example demonstrating how to define a LeapFunction with various parameter types. ```APIDOC ## Example Function Definition This example shows how to define a function to query weather information. ### Code Example ```swift LeapFunction( name: "get_weather", description: "Query the weather of cities", parameters: [ LeapFunctionParameter( name: "cities", type: LeapFunctionParameterType.array( ArrayType(itemType: .string(StringType())) ), description: "Names of the cities to query weather for" ), LeapFunctionParameter( name: "unit", type: LeapFunctionParameterType.string( StringType(enumValues: ["celsius", "fahrenheit"])), description: "Temperature unit (celsius or fahrenheit)" ), ] ) ``` ``` -------------------------------- ### Example of defining a function Source: https://docs.liquid.ai/deployment/on-device/ios/function-calling A comprehensive example demonstrating how to construct a LeapFunction with array and string parameters. ```swift LeapFunction( name: "get_weather", description: "Query the weather of cities", parameters: [ LeapFunctionParameter( name: "cities", type: LeapFunctionParameterType.array( ArrayType(itemType: .string(StringType())) ), description: "Names of the cities to query weather for" ), LeapFunctionParameter( name: "unit", type: LeapFunctionParameterType.string( StringType(enumValues: ["celsius", "fahrenheit"])), description: "Temperature unit (celsius or fahrenheit)" ), ] ) ```