|
Download llamacpp/sample.md from forgedgoods/forge-dataset-prep-samples: direct link, hf CLI and curl.
- Browser
- Download file 11 kB
-
https://huggingface.co/datasets/forgedgoods/forge-dataset-prep-samples/resolve/main/llamacpp/sample.md
- Command line
-
hf download hf://datasets/forgedgoods/forge-dataset-prep-samples/llamacpp/sample.md
-
curl -L -o sample.md https://huggingface.co/datasets/forgedgoods/forge-dataset-prep-samples/resolve/main/llamacpp/sample.md
11 kB
| # Sample — first 20 chunks (of 399) | |
| ## a96e1380af54add9 · docs/android.md · Android · L2-22 · ~516 tok · flags:- | |
| ``` | |
| # Android | |
| ## Build GUI binding using Android Studio | |
| Import the `examples/llama.android` directory into Android Studio, then perform a Gradle sync and build the project. | |
|  | |
| This Android binding supports hardware acceleration up to `SME2` for **Arm** and `AMX` for **x86-64** CPUs on Android and ChromeOS devices. | |
| It a… | |
| ``` | |
| ## 477ad045a927001d · docs/android.md · Android > Build CLI on Android using Termux · L24-53 · ~358 tok · flags:- | |
| ``` | |
| ## Build CLI on Android using Termux | |
| [Termux](https://termux.dev/en/) is an Android terminal emulator and Linux environment app (no root required). As of writing, Termux is available experimentally in the Google Play Store; otherwise, it may be obtained directly from the project repo or on F-Droid. | |
| With Termux, you can install and run `llama.cpp` as if the environment were Linux. Once in the Ter… | |
| ``` | |
| ## d5d2e67af4e71451 · docs/android.md · Android > Cross-compile CLI using Android NDK · L55-105 · ~597 tok · flags:- | |
| ``` | |
| ## Cross-compile CLI using Android NDK | |
| It's possible to build `llama.cpp` for Android on your host system via CMake and the Android NDK. If you are interested in this path, ensure you already have an environment prepared to cross-compile programs for Android (i.e., install the Android SDK/NDK and set `ANDROID_NDK` to the NDK root). Note that, unlike desktop environments, the Android environment sh… | |
| ``` | |
| ## 74c29a7f9eba3fce · docs/android.md · Android > Cross-compile CLI using Android NDK · L107-107 · ~88 tok · flags:short | |
| ``` | |
| Be aware that Android will not find the library path `lib` on its own, so we must specify `LD_LIBRARY_PATH` in order to run the installed executables. Android does support `RPATH` in later API levels, so this could change in the future. Refer to the previous section for information about `context-size` (very important!) and running other `examples`. | |
| ``` | |
| ## d41c60a4ad16e771 · docs/autoparser.md · Auto-Parser Architecture · L1-17 · ~248 tok · flags:- | |
| ``` | |
| # Auto-Parser Architecture | |
| The auto-parser automatically analyzes chat templates to determine how to parse model outputs, including content, reasoning, and tool calls. | |
| ## Overview | |
| The unified auto-parser uses a pure differential, compositional approach (inspired by the `git diff` algorithm) to analyze chat templates: | |
| **Core Philosophy**: | |
| - **Minimize Hardcoded Patterns**: All markers extracte… | |
| ``` | |
| ## fe0cb1204bc3f557 · docs/autoparser.md · Auto-Parser Architecture > Data Structures · L19-29 · ~150 tok · flags:- | |
| ``` | |
| ## Data Structures | |
| All structs are defined in [common/chat-auto-parser.h](common/chat-auto-parser.h). | |
| ### Top-Level: `autoparser` (main analyzer and generator) | |
| [common/chat-auto-parser.h:367-388](common/chat-auto-parser.h#L367-L388) — top-level analysis result aggregating `jinja_caps`, `reasoning`, `content`, and `tools` sub-analyses, plus `preserved_tokens` (union of all non-empty markers). | |
| #… | |
| ``` | |
| ## e9e9218ffcdf997e · docs/autoparser.md · Auto-Parser Architecture > Data Structures > `analyze_content` · L31-41 · ~299 tok · flags:- | |
| ``` | |
| ### `analyze_content` | |
| [common/chat-auto-parser.h:280-295](common/chat-auto-parser.h#L280-L295) — content analysis result: `mode` enum, `start`/`end` markers, and `requires_nonnull_content` flag. | |
| ### `analyze_tools` and its sub-structs | |
| - [common/chat-auto-parser.h:176-194](common/chat-auto-parser.h#L176-L194) — `tool_format_analysis`: `mode` enum, `section_start/end`, `per_call_start/end`, JSON … | |
| ``` | |
| ## 023f3895f4739548 · docs/autoparser.md · Auto-Parser Architecture > Data Structures > Enums · L43-59 · ~466 tok · flags:- | |
| ``` | |
| ### Enums | |
| **`reasoning_mode`**: How the template handles reasoning/thinking blocks. | |
| | Value | Description | | |
| |-----------------|-----------------------------------------------------------------------------------| | |
| | `NONE` | No reasoning markers detected | | |
| | … | |
| ``` | |
| ## 0867e55f016cb14d · docs/autoparser.md · Auto-Parser Architecture > Data Structures > Enums · L61-89 · ~472 tok · flags:- | |
| ``` | |
| 1. **Start+end in generation prompt** (e.g. `<think></think>\n`): the parser sees reasoning as opened and immediately closed; whitespace-only reasoning content is discarded. | |
| 2. **Only start in generation prompt** (e.g. `<think>\n`): the parser sees reasoning as already open. | |
| 3. **Start marker present but not at the end** (e.g. Apriel's `<|begin_assistant|>` followed by boilerplate): the marker is … | |
| ``` | |
| ## ca10ede50f4ea908 · docs/autoparser.md · Auto-Parser Architecture > Tool Calling Formats · L91-122 · ~158 tok · flags:- | |
| ``` | |
| ## Tool Calling Formats | |
| ### JSON_NATIVE | |
| **Structure**: The entire tool call (function name, arguments, values) is in JSON format. Optional enclosing tags around the section. | |
| **Detection**: Function name appears inside a JSON structure (quotes preceded by `{` or `:`). | |
| **Examples**: | |
| Standard OpenAI-style: | |
| ```json | |
| <tool_call> | |
| {"name": "get_weather", "arguments": {"location": "Paris", "unit": "c… | |
| ``` | |
| ## 852f8936252ddbc0 · docs/autoparser.md · Auto-Parser Architecture > Tool Calling Formats > TAG_WITH_JSON · L124-178 · ~276 tok · flags:- | |
| ``` | |
| ### TAG_WITH_JSON | |
| **Structure**: Function name is outside JSON, in tag attributes or XML-style tags. Arguments are a JSON object. | |
| **Detection**: Function name not in JSON, but argument names appear in JSON context. | |
| **Examples**: | |
| Functionary v3.1: | |
| ```xml | |
| <function=get_weather>{"location": "Paris", "unit": "celsius"}</function> | |
| ``` | |
| MiniMax: | |
| ```xml | |
| <minimax:tool_call> | |
| <tool_name>calculate</too… | |
| ``` | |
| ## 286137bbf0bf2d31 · docs/autoparser.md · Auto-Parser Architecture > Analysis Flow · L180-240 · ~599 tok · flags:- | |
| ``` | |
| ## Analysis Flow | |
| ```text | |
| autoparser::autoparser(tmpl) | |
| | | |
| |-- Phase 1: analyze_reasoning(tmpl, jinja_caps.supports_tool_calls) | |
| | |-- R1: compare_reasoning_presence() — with/without reasoning_content field | |
| | |-- R2: compare_thinking_enabled() — enable_thinking=false vs true | |
| | '-- R3: compare_reasoning_scope() — reasoning+content vs reasoning+tools | |
| | … | |
| ``` | |
| ## 0032c38d3466a5fe · docs/autoparser.md · Auto-Parser Architecture > Entry Point · L242-265 · ~355 tok · flags:- | |
| ``` | |
| ## Entry Point | |
| The auto-parser is invoked in [common/chat.cpp:1280-1310](common/chat.cpp#L1280-L1310) in `common_chat_templates_apply_jinja`. A few specialized templates are handled first (Ministral/Magistral Large 3, GPT-OSS with `<|channel|>`, Functionary v3.2 with `>>>all`), then the auto-parser handles everything else via `autoparser::autoparser` + `peg_generator::generate_parser`. | |
| ## Algori… | |
| ``` | |
| ## dff12acd2c518dfc · docs/autoparser.md · Auto-Parser Architecture > Algorithm Details > Phase 1: Reasoning Analysis · L267-300 · ~490 tok · flags:- | |
| ``` | |
| ### Phase 1: Reasoning Analysis | |
| **R1 — `compare_reasoning_presence()`**: Compares assistant message with vs without a `reasoning_content` field. | |
| - Searches `diff.right` (output with reasoning) for the reasoning content needle | |
| - Uses PEG parsers to find surrounding markers: | |
| - If both pre/post markers found in `diff.right` → `TAG_BASED` | |
| - If both found but post marker only in the full output B… | |
| ``` | |
| ## 1925a77bb6d7b386 · docs/autoparser.md · Auto-Parser Architecture > Algorithm Details > Phase 3: Tool Call Analysis · L302-328 · ~502 tok · flags:- | |
| ``` | |
| ### Phase 3: Tool Call Analysis | |
| **T1 — `analyze_tool_calls()`**: Compares no-tools vs with-tools output. | |
| - Extracts the tool call section as `diff.right` | |
| - Calls `analyze_tool_call_format()` which first strips reasoning markers from the haystack, then: | |
| - Calls `in_json_haystack()` for both function name and argument name needles | |
| - `in_json_haystack()` uses a PEG parser to check whether the n… | |
| ``` | |
| ## 1455ebf90bd9203d · docs/autoparser.md · Auto-Parser Architecture > Algorithm Details > Phase 3: Tool Call Analysis · L330-349 · ~343 tok · flags:- | |
| ``` | |
| - **A1 `extract_argument_name_markers()`**: Compares `arg_name_A` vs `arg_name_B` (two different argument names). | |
| - Finds shared surrounding structure → `arguments.name_prefix`, `arguments.name_suffix` | |
| - **A2 `extract_argument_value_markers()`**: Compares argument value `"XXXX"` vs `"YYYY"` (same arg, different value). | |
| - Finds markers surrounding the value → `arguments.value_prefix`, `argument… | |
| ``` | |
| ## 8414a38a398498be · docs/autoparser.md · Auto-Parser Architecture > Algorithm Details > Workarounds · L351-359 · ~280 tok · flags:- | |
| ``` | |
| ### Workarounds | |
| A workaround array in `common/chat-diff-analyzer.cpp` applies post-hoc patches after analysis. Each workaround is a lambda that inspects the template source and overrides analysis results. Current workarounds: | |
| 1. **Old Qwen/DeepSeek thinking templates** — source contains `content.split('</think>')` but not `<SPECIAL_12>`: sets `reasoning.mode = TAG_BASED` with `<think>`/`</think>… | |
| ``` | |
| ## 2ed200de6cc43582 · docs/autoparser.md · Auto-Parser Architecture > Algorithm Details > Parser Building · L361-373 · ~274 tok · flags:- | |
| ``` | |
| ### Parser Building | |
| Each analyzer struct (`analyze_reasoning`, `analyze_content`, `analyze_tools`) implements `build_parser(parser_build_context&)`. They share a `parser_build_context` that carries the PEG builder, inference inputs, the pre-built reasoning parser, and a pointer to the content analyzer. | |
| #### Reasoning Parser (`analyze_reasoning::build_parser`) | |
| | Mode … | |
| ``` | |
| ## 5088df62293714ab · docs/autoparser.md · Auto-Parser Architecture > Algorithm Details > Parser Building > Content Parser (`analyze_content::build_parser`) · L375-383 · ~160 tok · flags:- | |
| ``` | |
| #### Content Parser (`analyze_content::build_parser`) | |
| | Condition | Parser | | |
| |----------------------------------------|---------------------------------------------------------------------------------| | |
| | `json_schema` present | `reasoning + space() + content(schema(json(), "respo… | |
| ``` | |
| ## 56eec19f9bcabf74 · docs/autoparser.md · Auto-Parser Architecture > Algorithm Details > Parser Building > Tool Parsers (`analyze_tools::build_parser`) · L385-423 · ~437 tok · flags:- | |
| ``` | |
| #### Tool Parsers (`analyze_tools::build_parser`) | |
| Dispatches by `format.mode`: | |
| **`build_tool_parser_json_native()`**: Calls `p.standard_json_tools()` which internally dispatches to: | |
| - `build_json_tools_function_is_key()` — function name is the JSON key: `{"get_weather": {...}}` | |
| - `build_json_tools_nested_keys()` — nested: `{"function": {"name": "X", "arguments": {...}}}` | |
| - `build_json_tools_fla… | |
| ``` | |