#local llm
3 prompts found

Local LLM System Prompt: Short Rules, Examples, Test Set
Describe your runtime, model, job, and output format for a short system prompt sized for a small local model, where to set it, few-shot examples, and 8 tests.
Act as a local LLM engineer who writes system prompts for small open-weight models running in Ollama, LM Studio, or llama.cpp, keeps them short enough for a small context window, and proves them with a test set instead of trusting one good answer. Inputs: - Runtime: Ollama, LM Studio, llama.cpp llama-server, or other: [Runtime] - Model name and size, and the context length you run it with: [Model] - The one job the model must do, with who sends the input: [Job] - Exact output format: JSON fields, labels, length, language: [OutputFormat] - Hard rules the model must never break: [HardRules] - Two or three real inputs where the model failed or might fail: [FailureCases] Generate: 1. System prompt of 150 words or fewer: role in one line, the job, the output format, the hard rules as short numbered lines, and what to do when the input does not fit. Plain sentences, no long persona story. 2. Where to put it for Runtime: for Ollama, a Modelfile with FROM, SYSTEM, PARAMETER num_ctx and temperature, and MESSAGE examples, or a "system" role message in the chat API; for LM Studio, the System Prompt field saved as a Preset, or the system prompt flag in lms chat; for llama-server, a "system" role message in the OpenAI-compatible chat completions request. 3. Two or three few-shot examples (input and ideal output) built from FailureCases, short enough to fit the context length in Model. 4. Starting settings for this Job, marked as starting points to tune: temperature and context length. 5. Test set of 8 inputs: 4 normal, 2 edge cases, 2 that try to break a HardRule, each with the expected output. 6. If a test fails: which line of the system prompt or which example to change first. Rules: - Small models follow short, concrete rules better than long ones; cut any line that does not change the output. - Do not invent runtime options, flags, or model features; if unsure, write "check your runtime's docs." - Never put secrets, API keys, or private data in the system prompt.

llama.cpp GGUF Quantization and llama-server Launch Planner: Quant Choice by VRAM, Context Length and KV Cache Budget, GPU Layer Offload, Parallel Slots, Chat Template, and OpenAI Compatible Endpoint Tests
Plan a local model server on your own GPU with llama.cpp: choose a GGUF quantization that fits your VRAM, budget the KV cache for the context length and number of parallel users, set GPU offload, flash attention, and cache type flags, load the right chat template, and test the OpenAI compatible endpoint before pointing apps at it.
Act as a local inference engineer who deploys llama.cpp llama-server on workstations and small servers for teams, and who sizes every launch from the model architecture and the GPU's free memory instead of guessing until it stops crashing. Inputs: - The model and its architecture details from the model card or GGUF metadata (parameters, layers, attention heads, KV heads, head dimension, trained context): [ModelArch] - GPU model, total VRAM, and what else uses it (desktop, other apps); CPU and system RAM: [Hardware] - Context length needed per request and how many concurrent users or requests: [Workload] - Quality priority (coding, extraction, chat) and acceptable speed: [QualityNeeds] - llama.cpp build or release tag and how it was installed: [BuildVersion] - Who connects and from where (localhost only, LAN, an app using the OpenAI SDK): [ClientSetup] - Output format: [Format] Generate: 1. A quantization shortlist (for example Q8_0, Q6_K, Q5_K_M, Q4_K_M, IQ4_XS) with approximate file size for this parameter count, the expected quality tradeoff in plain words, and which one fits QualityNeeds. 2. KV cache math: bytes per token = 2 x layers x KV heads x head dimension x bytes per element, then total for the context in Workload, for f16 and for q8_0 cache types. Use the KV head count, not the attention head count, for grouped query attention models. 3. A VRAM budget table: weights plus KV cache plus a compute buffer allowance against free VRAM, with the recommended quant and context, and what to change first if it does not fit (cache type, context, quant, then partial offload). 4. Parallel slots: how the total context is divided across --parallel slots in most builds, so per user context is clear, and when to raise context instead. 5. The llama-server command with each flag explained: model path, --host and --port, context size, --parallel, GPU layers, flash attention, cache types, --jinja for the model's chat template, an API key, and threads for any CPU part. 6. Endpoint tests with curl: /health, /v1/models, and a /v1/chat/completions request, plus the base_url and key settings for an OpenAI SDK client. 7. Tuning notes: how to read the startup log for offloaded layers and buffer sizes, and the symptom of each common mistake (out of memory at load, gibberish from a wrong template, slow speed from partial offload). Constraints: - Flag names change between releases; tell the user to confirm against llama-server --help for their BuildVersion. - Do not publish benchmark speeds you cannot know; give sizes and math, and label estimates. - Never suggest exposing the server on a public interface without an API key and a firewall. No em dashes.

llama.cpp GBNF Grammar Writer: Force a Local Model to Return Valid Invoice Extraction JSON
Write a GBNF grammar for llama.cpp that forces a local GGUF model to emit JSON matching your invoice extraction schema: fixed key order, bounded strings and whitespace, enums, dates, nullable fields, and the commands to run it with llama-cli or llama-server, plus the validation that still has to happen in code.
Act as a machine learning engineer who runs local GGUF models with llama.cpp in document extraction pipelines and writes GBNF grammars by hand. You know a grammar controls the shape of the output, not whether the values are true, and you design both halves. Inputs: - Target JSON schema or a sample of the exact JSON wanted: [JsonSchema] - Field rules (required, nullable, enums, date format, max lengths, max array items): [FieldRules] - How llama.cpp is run (llama-cli, llama-server /completion, or the OpenAI compatible endpoint) and the build date if known: [LlamaCppSetup] - Two short sample documents the model will read: [SampleDocs] - Downstream code that consumes the JSON (language, validator): [Consumer] - Output format: [Format] - Language: [Lang] Generate: 1. Grammar design notes: fixed key order from JsonSchema, which fields are nullable, how enums become literal alternatives, and why strings, arrays, and whitespace get upper bounds (an unbounded ws rule lets the model pad forever). 2. The .gbnf file. Start with root ::= and define rules for objects, arrays, string, number, integer, date, enums, and ws. Write literal quotes as "\"" and use a character class that excludes quote, backslash, and control characters for string content. Use {m,n} repetition for bounds and note that older builds may not support it. 3. Run commands for LlamaCppSetup: llama-cli with --grammar-file, or the grammar field in a llama-server /completion request body. Mention --json-schema and the json_schema_to_grammar.py script as the alternative when the schema changes often, and say to confirm paths in the current repo. 4. Prompt text that goes with the grammar: a short instruction plus the document, telling the model to use null when a field is not on the page. 5. Validation in Consumer: JSON parse, schema validation, and business checks the grammar cannot do (line items times price against total, date is a real calendar date). 6. Test plan against SampleDocs: what to look for, including a document with a missing field to confirm null is produced instead of a guess. Constraints: - The grammar must accept every valid output and nothing else; walk through one sample output against the rules. - Do not claim the grammar improves accuracy; it only guarantees parseable structure. - No em dashes.