|
ember.cpp 0.1.0
C++ inference engine for Llama-family and paperkiln models (CPU, CUDA, WebAssembly)
|
Command-line interface for TinyLlama text generation. More...
#include <algorithm>#include <cctype>#include <cstdio>#include <iomanip>#include <iostream>#include <memory>#include <sstream>#include <stdexcept>#include <string>#include <vector>#include "api.h"#include "logger.h"
Go to the source code of this file.
Functions | |
| std::string | trim_whitespace (const std::string &s) |
| void | print_usage (const char *program_name) |
| int | main (int argc, char **argv) |
Command-line interface for TinyLlama text generation.
This program provides a command-line interface for generating text using TinyLlama models. It supports both GGUF and SafeTensors model formats. The program automatically applies Q:A formatting to prompts, which is required for proper model responses in both formats.
Usage:
* tinyllama <model_path> <tokenizer_path> <num_threads> <prompt|chat|batch> [--system-prompt <system_prompt_string>] [initial_user_prompt] [max_tokens] [n_gpu_layers] [use_mmap] [temperature] [top_k] [top_p] [use_kv_quant] [use_batch_generation] [--batch-prompts "prompt1" "prompt2" ...] [--max-batch-size N] *
Arguments: model_path: Path to the model file (.gguf) or directory (SafeTensors). tokenizer_path: Path to the tokenizer file. num_threads: Number of threads to use for generation. prompt|chat|batch: 'prompt' for single prompt generation, 'chat' for interactive chat mode, 'batch' for batch processing. –system-prompt: (Optional) System prompt to guide the model. Default: empty. initial_user_prompt: (Optional) Initial user prompt string. Default: "Hello, world!" max_tokens: (Optional) Maximum number of tokens to generate. Default: 256 n_gpu_layers: (Optional) Number of layers to offload to GPU (-1 for all, 0 for none). Default: -1 (all layers on GPU if available) use_mmap: (Optional) Use mmap for GGUF files ('true' or 'false'). Default: true temperature: (Optional) Sampling temperature (e.g., 0.1). Lower is more deterministic. Default: 0.1 top_k: (Optional) Top-K sampling parameter (0 to disable). Default: 40 top_p: (Optional) Top-P/nucleus sampling parameter (0.0-1.0). Default: 0.9 use_kv_quant: (Optional) Use INT8 KVCache quantization on GPU ('true' or 'false'). Default: false use_batch_generation: (Optional) Use GPU batch generation for tokens ('true' or 'false'). Default: false –batch-prompts: (For batch mode) Multiple prompts in quotes, e.g., "prompt1" "prompt2" ... –max-batch-size: (For batch mode) Maximum batch size. Default: 8
Example: ./tinyllama ./models/model.gguf ./models/tokenizer.model 4 prompt –system-prompt "You are a helpful assistant." "What is the capital of France?" 128 0 true 0.1 40 0.9 true
Note: The program may automatically apply Q:A formatting to prompts (e.g., "Q: [prompt]\nA:") depending on the model type, as this can be required for proper responses.
Definition in file main.cpp.
Definition at line 89 of file main.cpp.
References Logger::error(), Logger::info(), j, ModelConfig::LLAMA3_TIKTOKEN, print_usage(), trim_whitespace(), and Logger::warning().
Definition at line 64 of file main.cpp.
References j.
Referenced by main().
| std::string trim_whitespace | ( | const std::string & | s | ) |