{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "0d641747",
   "metadata": {},
   "source": [
    "## Llama CPP\n",
    "\n",
    "Lecture 19 | CMU ANLP Fall 2025 | Instructor: Sean Welleck\n",
    "\n",
    "This notebook shows running inference with a quantized Qwen3-8B via the llama cpp server.\n",
    "\n",
    "After running the cells below, navigate to http://localhost:8080/ to interact with the model."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "70d8ee53",
   "metadata": {},
   "outputs": [],
   "source": [
    "!brew install llama.cpp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "df3de2db",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ggml_metal_device_init: tensor API disabled for pre-M5 device\n",
      "ggml_metal_library_init: using embedded metal library\n",
      "ggml_metal_library_init: loaded in 0.022 sec\n",
      "ggml_metal_device_init: GPU name:   Apple M4\n",
      "ggml_metal_device_init: GPU family: MTLGPUFamilyApple9  (1009)\n",
      "ggml_metal_device_init: GPU family: MTLGPUFamilyCommon3 (3003)\n",
      "ggml_metal_device_init: GPU family: MTLGPUFamilyMetal3  (5001)\n",
      "ggml_metal_device_init: simdgroup reduction   = true\n",
      "ggml_metal_device_init: simdgroup matrix mul. = true\n",
      "ggml_metal_device_init: has unified memory    = true\n",
      "ggml_metal_device_init: has bfloat            = true\n",
      "ggml_metal_device_init: has tensor            = false\n",
      "ggml_metal_device_init: use residency sets    = true\n",
      "ggml_metal_device_init: use shared buffers    = true\n",
      "ggml_metal_device_init: recommendedMaxWorkingSetSize  = 11453.25 MB\n",
      "* Host huggingface.co:443 was resolved.\n",
      "* IPv6: (none)\n",
      "* IPv4: 3.167.112.38, 3.167.112.96, 3.167.112.45, 3.167.112.25\n",
      "*   Trying 3.167.112.38:443...\n",
      "* Connected to huggingface.co (3.167.112.38) port 443\n",
      "* ALPN: curl offers h2,http/1.1\n",
      "*  CAfile: /etc/ssl/cert.pem\n",
      "*  CApath: none\n",
      "* SSL connection using TLSv1.3 / AEAD-AES128-GCM-SHA256 / [blank] / UNDEF\n",
      "* ALPN: server accepted h2\n",
      "* Server certificate:\n",
      "*  subject: CN=huggingface.co\n",
      "*  start date: Apr 13 00:00:00 2025 GMT\n",
      "*  expire date: May 12 23:59:59 2026 GMT\n",
      "*  subjectAltName: host \"huggingface.co\" matched cert's \"huggingface.co\"\n",
      "*  issuer: C=US; O=Amazon; CN=Amazon RSA 2048 M02\n",
      "*  SSL certificate verify ok.\n",
      "* using HTTP/2\n",
      "* [HTTP/2] [1] OPENED stream for https://huggingface.co/v2/Qwen/Qwen3-8B-GGUF/manifests/Q4_K_M\n",
      "* [HTTP/2] [1] [:method: GET]\n",
      "* [HTTP/2] [1] [:scheme: https]\n",
      "* [HTTP/2] [1] [:authority: huggingface.co]\n",
      "* [HTTP/2] [1] [:path: /v2/Qwen/Qwen3-8B-GGUF/manifests/Q4_K_M]\n",
      "* [HTTP/2] [1] [user-agent: llama-cpp]\n",
      "* [HTTP/2] [1] [accept: application/json]\n",
      "> GET /v2/Qwen/Qwen3-8B-GGUF/manifests/Q4_K_M HTTP/2\n",
      "Host: huggingface.co\n",
      "User-Agent: llama-cpp\n",
      "Accept: application/json\n",
      "\n",
      "* Request completely sent off\n",
      "< HTTP/2 200 \n",
      "< content-type: application/json; charset=utf-8\n",
      "< content-length: 1128\n",
      "< date: Tue, 11 Nov 2025 19:59:34 GMT\n",
      "< etag: W/\"468-s23Zs47Cv1pa92kkfI/4vBNEXPc\"\n",
      "< x-powered-by: huggingface-moon\n",
      "< x-request-id: Root=1-691395a6-0f5453d51799ed551ef50b10\n",
      "< ratelimit: \"pages\";r=99;t=194\n",
      "< ratelimit-policy: \"fixed window\";\"pages\";q=100;w=300\n",
      "< cross-origin-opener-policy: same-origin\n",
      "< referrer-policy: strict-origin-when-cross-origin\n",
      "< access-control-max-age: 86400\n",
      "< access-control-allow-origin: https://huggingface.co\n",
      "< vary: Origin\n",
      "< access-control-expose-headers: X-Repo-Commit,X-Request-Id,X-Error-Code,X-Error-Message,X-Total-Count,ETag,Link,Accept-Ranges,Content-Range,X-Linked-Size,X-Linked-ETag,X-Xet-Hash\n",
      "< x-cache: Miss from cloudfront\n",
      "< via: 1.1 7ba8238566c8641cae9d38ebcb67e0e8.cloudfront.net (CloudFront)\n",
      "< x-amz-cf-pop: IAD55-P8\n",
      "< x-amz-cf-id: O4purX4ZXYrcIDZWgw8sJJEXNWWCjOEQMWH11YHYjS15HVxd6-lu8A==\n",
      "< \n",
      "* Connection #0 to host huggingface.co left intact\n",
      "common_download_file_single_online: using cached file: /Users/wellecks/Library/Caches/llama.cpp/Qwen_Qwen3-8B-GGUF_Qwen3-8B-Q4_K_M.gguf\n",
      "main: setting n_parallel = 4 and kv_unified = true (add -kvu to disable this)\n",
      "\u001b[0mbuild: 6990 (53d7d21e6) with Apple clang version 17.0.0 (clang-1700.4.4.1) for arm64-apple-darwin24.6.0\n",
      "system info: n_threads = 4, n_threads_batch = 4, total_threads = 10\n",
      "\n",
      "system_info: n_threads = 4 (n_threads_batch = 4) / 10 | Metal : EMBED_LIBRARY = 1 | CPU : NEON = 1 | ARM_FMA = 1 | FP16_VA = 1 | DOTPROD = 1 | LLAMAFILE = 1 | ACCELERATE = 1 | REPACK = 1 | \n",
      "\n",
      "main: binding port with default address family\n",
      "main: HTTP server is listening, hostname: 127.0.0.1, port: 8080, http threads: 9\n",
      "main: loading model\n",
      "srv    load_model: loading model '/Users/wellecks/Library/Caches/llama.cpp/Qwen_Qwen3-8B-GGUF_Qwen3-8B-Q4_K_M.gguf'\n",
      "llama_model_load_from_file_impl: using device Metal (Apple M4) (unknown id) - 10922 MiB free\n",
      "llama_model_loader: loaded meta data with 28 key-value pairs and 399 tensors from /Users/wellecks/Library/Caches/llama.cpp/Qwen_Qwen3-8B-GGUF_Qwen3-8B-Q4_K_M.gguf (version GGUF V3 (latest))\n",
      "llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output.\n",
      "llama_model_loader: - kv   0:                       general.architecture str              = qwen3\n",
      "llama_model_loader: - kv   1:                               general.type str              = model\n",
      "llama_model_loader: - kv   2:                               general.name str              = Qwen3 8B Awq Compatible Instruct\n",
      "llama_model_loader: - kv   3:                           general.finetune str              = awq-compatible-Instruct\n",
      "llama_model_loader: - kv   4:                           general.basename str              = Qwen3\n",
      "llama_model_loader: - kv   5:                         general.size_label str              = 8B\n",
      "llama_model_loader: - kv   6:                          qwen3.block_count u32              = 36\n",
      "llama_model_loader: - kv   7:                       qwen3.context_length u32              = 40960\n",
      "llama_model_loader: - kv   8:                     qwen3.embedding_length u32              = 4096\n",
      "llama_model_loader: - kv   9:                  qwen3.feed_forward_length u32              = 12288\n",
      "llama_model_loader: - kv  10:                 qwen3.attention.head_count u32              = 32\n",
      "llama_model_loader: - kv  11:              qwen3.attention.head_count_kv u32              = 8\n",
      "llama_model_loader: - kv  12:                       qwen3.rope.freq_base f32              = 1000000.000000\n",
      "llama_model_loader: - kv  13:     qwen3.attention.layer_norm_rms_epsilon f32              = 0.000001\n",
      "llama_model_loader: - kv  14:                 qwen3.attention.key_length u32              = 128\n",
      "llama_model_loader: - kv  15:               qwen3.attention.value_length u32              = 128\n",
      "llama_model_loader: - kv  16:                       tokenizer.ggml.model str              = gpt2\n",
      "llama_model_loader: - kv  17:                         tokenizer.ggml.pre str              = qwen2\n",
      "llama_model_loader: - kv  18:                      tokenizer.ggml.tokens arr[str,151936]  = [\"!\", \"\\\"\", \"#\", \"$\", \"%\", \"&\", \"'\", ...\n",
      "llama_model_loader: - kv  19:                  tokenizer.ggml.token_type arr[i32,151936]  = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...\n",
      "llama_model_loader: - kv  20:                      tokenizer.ggml.merges arr[str,151387]  = [\"Ġ Ġ\", \"ĠĠ ĠĠ\", \"i n\", \"Ġ t\",...\n",
      "llama_model_loader: - kv  21:                tokenizer.ggml.eos_token_id u32              = 151645\n",
      "llama_model_loader: - kv  22:            tokenizer.ggml.padding_token_id u32              = 151643\n",
      "llama_model_loader: - kv  23:                tokenizer.ggml.bos_token_id u32              = 151643\n",
      "llama_model_loader: - kv  24:               tokenizer.ggml.add_bos_token bool             = false\n",
      "llama_model_loader: - kv  25:                    tokenizer.chat_template str              = {%- if tools %}\\n    {{- '<|im_start|>...\n",
      "llama_model_loader: - kv  26:               general.quantization_version u32              = 2\n",
      "llama_model_loader: - kv  27:                          general.file_type u32              = 15\n",
      "llama_model_loader: - type  f32:  145 tensors\n",
      "llama_model_loader: - type q4_K:  217 tensors\n",
      "llama_model_loader: - type q6_K:   37 tensors\n",
      "print_info: file format = GGUF V3 (latest)\n",
      "print_info: file type   = Q4_K - Medium\n",
      "print_info: file size   = 4.68 GiB (4.90 BPW) \n",
      "load: printing all EOG tokens:\n",
      "load:   - 151643 ('<|endoftext|>')\n",
      "load:   - 151645 ('<|im_end|>')\n",
      "load:   - 151662 ('<|fim_pad|>')\n",
      "load:   - 151663 ('<|repo_name|>')\n",
      "load:   - 151664 ('<|file_sep|>')\n",
      "load: special tokens cache size = 26\n",
      "load: token to piece cache size = 0.9311 MB\n",
      "print_info: arch             = qwen3\n",
      "print_info: vocab_only       = 0\n",
      "print_info: n_ctx_train      = 40960\n",
      "print_info: n_embd           = 4096\n",
      "print_info: n_embd_inp       = 4096\n",
      "print_info: n_layer          = 36\n",
      "print_info: n_head           = 32\n",
      "print_info: n_head_kv        = 8\n",
      "print_info: n_rot            = 128\n",
      "print_info: n_swa            = 0\n",
      "print_info: is_swa_any       = 0\n",
      "print_info: n_embd_head_k    = 128\n",
      "print_info: n_embd_head_v    = 128\n",
      "print_info: n_gqa            = 4\n",
      "print_info: n_embd_k_gqa     = 1024\n",
      "print_info: n_embd_v_gqa     = 1024\n",
      "print_info: f_norm_eps       = 0.0e+00\n",
      "print_info: f_norm_rms_eps   = 1.0e-06\n",
      "print_info: f_clamp_kqv      = 0.0e+00\n",
      "print_info: f_max_alibi_bias = 0.0e+00\n",
      "print_info: f_logit_scale    = 0.0e+00\n",
      "print_info: f_attn_scale     = 0.0e+00\n",
      "print_info: n_ff             = 12288\n",
      "print_info: n_expert         = 0\n",
      "print_info: n_expert_used    = 0\n",
      "print_info: n_expert_groups  = 0\n",
      "print_info: n_group_used     = 0\n",
      "print_info: causal attn      = 1\n",
      "print_info: pooling type     = -1\n",
      "print_info: rope type        = 2\n",
      "print_info: rope scaling     = linear\n",
      "print_info: freq_base_train  = 1000000.0\n",
      "print_info: freq_scale_train = 1\n",
      "print_info: n_ctx_orig_yarn  = 40960\n",
      "print_info: rope_finetuned   = unknown\n",
      "print_info: model type       = 8B\n",
      "print_info: model params     = 8.19 B\n",
      "print_info: general.name     = Qwen3 8B Awq Compatible Instruct\n",
      "print_info: vocab type       = BPE\n",
      "print_info: n_vocab          = 151936\n",
      "print_info: n_merges         = 151387\n",
      "print_info: BOS token        = 151643 '<|endoftext|>'\n",
      "print_info: EOS token        = 151645 '<|im_end|>'\n",
      "print_info: EOT token        = 151645 '<|im_end|>'\n",
      "print_info: PAD token        = 151643 '<|endoftext|>'\n",
      "print_info: LF token         = 198 'Ċ'\n",
      "print_info: FIM PRE token    = 151659 '<|fim_prefix|>'\n",
      "print_info: FIM SUF token    = 151661 '<|fim_suffix|>'\n",
      "print_info: FIM MID token    = 151660 '<|fim_middle|>'\n",
      "print_info: FIM PAD token    = 151662 '<|fim_pad|>'\n",
      "print_info: FIM REP token    = 151663 '<|repo_name|>'\n",
      "print_info: FIM SEP token    = 151664 '<|file_sep|>'\n",
      "print_info: EOG token        = 151643 '<|endoftext|>'\n",
      "print_info: EOG token        = 151645 '<|im_end|>'\n",
      "print_info: EOG token        = 151662 '<|fim_pad|>'\n",
      "print_info: EOG token        = 151663 '<|repo_name|>'\n",
      "print_info: EOG token        = 151664 '<|file_sep|>'\n",
      "print_info: max token length = 256\n",
      "load_tensors: loading model tensors, this can take a while... (mmap = true)\n",
      "load_tensors: offloading 36 repeating layers to GPU\n",
      "load_tensors: offloading output layer to GPU\n",
      "load_tensors: offloaded 37/37 layers to GPU\n",
      "load_tensors:   CPU_Mapped model buffer size =   333.84 MiB\n",
      "load_tensors: Metal_Mapped model buffer size =  4789.19 MiB\n",
      ".....................................................................................\n",
      "llama_context: constructing llama_context\n",
      "llama_context: n_seq_max     = 4\n",
      "llama_context: n_ctx         = 4096\n",
      "llama_context: n_ctx_seq     = 4096\n",
      "llama_context: n_batch       = 2048\n",
      "llama_context: n_ubatch      = 512\n",
      "llama_context: causal_attn   = 1\n",
      "llama_context: flash_attn    = auto\n",
      "llama_context: kv_unified    = true\n",
      "llama_context: freq_base     = 1000000.0\n",
      "llama_context: freq_scale    = 1\n",
      "llama_context: n_ctx_seq (4096) < n_ctx_train (40960) -- the full capacity of the model will not be utilized\n",
      "\u001b[0mggml_metal_init: allocating\n",
      "ggml_metal_init: found device: Apple M4\n",
      "ggml_metal_init: picking default device: Apple M4\n",
      "ggml_metal_init: use fusion         = true\n",
      "ggml_metal_init: use concurrency    = true\n",
      "ggml_metal_init: use graph optimize = true\n",
      "llama_context:        CPU  output buffer size =     2.32 MiB\n",
      "llama_kv_cache:      Metal KV buffer size =   576.00 MiB\n",
      "llama_kv_cache: size =  576.00 MiB (  4096 cells,  36 layers,  4/1 seqs), K (f16):  288.00 MiB, V (f16):  288.00 MiB\n",
      "llama_context: Flash Attention was auto, set to enabled\n",
      "llama_context:      Metal compute buffer size =   304.75 MiB\n",
      "llama_context:        CPU compute buffer size =    16.01 MiB\n",
      "llama_context: graph nodes  = 1267\n",
      "llama_context: graph splits = 2\n",
      "common_init_from_params: added <|endoftext|> logit bias = -inf\n",
      "common_init_from_params: added <|im_end|> logit bias = -inf\n",
      "common_init_from_params: added <|fim_pad|> logit bias = -inf\n",
      "common_init_from_params: added <|repo_name|> logit bias = -inf\n",
      "common_init_from_params: added <|file_sep|> logit bias = -inf\n",
      "common_init_from_params: setting dry_penalty_last_n to ctx_size = 4096\n",
      "common_init_from_params: warming up the model with an empty run - please wait ... (--no-warmup to disable)\n",
      "\u001b[0msrv          init: initializing slots, n_slots = 4\n",
      "slot         init: id  0 | task -1 | new slot, n_ctx = 4096\n",
      "slot         init: id  1 | task -1 | new slot, n_ctx = 4096\n",
      "slot         init: id  2 | task -1 | new slot, n_ctx = 4096\n",
      "slot         init: id  3 | task -1 | new slot, n_ctx = 4096\n",
      "srv          init: prompt cache is enabled, size limit: 8192 MiB\n",
      "\u001b[0msrv          init: use `--cache-ram 0` to disable the prompt cache\n",
      "\u001b[0msrv          init: for more info see https://github.com/ggml-org/llama.cpp/pull/16391\n",
      "\u001b[0msrv          init: thinking = 0\n",
      "main: model loaded\n",
      "main: chat template, chat_template: {%- if tools %}\n",
      "    {{- '<|im_start|>system\\n' }}\n",
      "    {%- if messages[0].role == 'system' %}\n",
      "        {{- messages[0].content + '\\n\\n' }}\n",
      "    {%- endif %}\n",
      "    {{- \"# Tools\\n\\nYou may call one or more functions to assist with the user query.\\n\\nYou are provided with function signatures within <tools></tools> XML tags:\\n<tools>\" }}\n",
      "    {%- for tool in tools %}\n",
      "        {{- \"\\n\" }}\n",
      "        {{- tool | tojson }}\n",
      "    {%- endfor %}\n",
      "    {{- \"\\n</tools>\\n\\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\\n<tool_call>\\n{\\\"name\\\": <function-name>, \\\"arguments\\\": <args-json-object>}\\n</tool_call><|im_end|>\\n\" }}\n",
      "{%- else %}\n",
      "    {%- if messages[0].role == 'system' %}\n",
      "        {{- '<|im_start|>system\\n' + messages[0].content + '<|im_end|>\\n' }}\n",
      "    {%- endif %}\n",
      "{%- endif %}\n",
      "{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}\n",
      "{%- for index in range(ns.last_query_index, -1, -1) %}\n",
      "    {%- set message = messages[index] %}\n",
      "    {%- if ns.multi_step_tool and message.role == \"user\" and not('<tool_response>' in message.content and '</tool_response>' in message.content) %}\n",
      "        {%- set ns.multi_step_tool = false %}\n",
      "        {%- set ns.last_query_index = index %}\n",
      "    {%- endif %}\n",
      "{%- endfor %}\n",
      "{%- for message in messages %}\n",
      "    {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) %}\n",
      "        {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n",
      "    {%- elif message.role == \"assistant\" %}\n",
      "        {%- set content = message.content %}\n",
      "        {%- set reasoning_content = '' %}\n",
      "        {%- if message.reasoning_content is defined and message.reasoning_content is not none %}\n",
      "            {%- set reasoning_content = message.reasoning_content %}\n",
      "        {%- else %}\n",
      "            {%- if '</think>' in message.content %}\n",
      "                {%- set content = message.content.split('</think>')[-1].lstrip('\\n') %}\n",
      "                {%- set reasoning_content = message.content.split('</think>')[0].rstrip('\\n').split('<think>')[-1].lstrip('\\n') %}\n",
      "            {%- endif %}\n",
      "        {%- endif %}\n",
      "        {%- if loop.index0 > ns.last_query_index %}\n",
      "            {%- if loop.last or (not loop.last and reasoning_content) %}\n",
      "                {{- '<|im_start|>' + message.role + '\\n<think>\\n' + reasoning_content.strip('\\n') + '\\n</think>\\n\\n' + content.lstrip('\\n') }}\n",
      "            {%- else %}\n",
      "                {{- '<|im_start|>' + message.role + '\\n' + content }}\n",
      "            {%- endif %}\n",
      "        {%- else %}\n",
      "            {{- '<|im_start|>' + message.role + '\\n' + content }}\n",
      "        {%- endif %}\n",
      "        {%- if message.tool_calls %}\n",
      "            {%- for tool_call in message.tool_calls %}\n",
      "                {%- if (loop.first and content) or (not loop.first) %}\n",
      "                    {{- '\\n' }}\n",
      "                {%- endif %}\n",
      "                {%- if tool_call.function %}\n",
      "                    {%- set tool_call = tool_call.function %}\n",
      "                {%- endif %}\n",
      "                {{- '<tool_call>\\n{\"name\": \"' }}\n",
      "                {{- tool_call.name }}\n",
      "                {{- '\", \"arguments\": ' }}\n",
      "                {%- if tool_call.arguments is string %}\n",
      "                    {{- tool_call.arguments }}\n",
      "                {%- else %}\n",
      "                    {{- tool_call.arguments | tojson }}\n",
      "                {%- endif %}\n",
      "                {{- '}\\n</tool_call>' }}\n",
      "            {%- endfor %}\n",
      "        {%- endif %}\n",
      "        {{- '<|im_end|>\\n' }}\n",
      "    {%- elif message.role == \"tool\" %}\n",
      "        {%- if loop.first or (messages[loop.index0 - 1].role != \"tool\") %}\n",
      "            {{- '<|im_start|>user' }}\n",
      "        {%- endif %}\n",
      "        {{- '\\n<tool_response>\\n' }}\n",
      "        {{- message.content }}\n",
      "        {{- '\\n</tool_response>' }}\n",
      "        {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n",
      "            {{- '<|im_end|>\\n' }}\n",
      "        {%- endif %}\n",
      "    {%- endif %}\n",
      "{%- endfor %}\n",
      "{%- if add_generation_prompt %}\n",
      "    {{- '<|im_start|>assistant\\n' }}\n",
      "    {%- if enable_thinking is defined and enable_thinking is false %}\n",
      "        {{- '<think>\\n\\n</think>\\n\\n' }}\n",
      "    {%- endif %}\n",
      "{%- endif %}, example_format: '<|im_start|>system\n",
      "You are a helpful assistant<|im_end|>\n",
      "<|im_start|>user\n",
      "Hello<|im_end|>\n",
      "<|im_start|>assistant\n",
      "Hi there<|im_end|>\n",
      "<|im_start|>user\n",
      "How are you?<|im_end|>\n",
      "<|im_start|>assistant\n",
      "'\n",
      "main: server is listening on http://127.0.0.1:8080 - starting the main loop\n",
      "srv  update_slots: all slots are idle\n",
      "srv  log_server_r: request: GET / 127.0.0.1 200\n",
      "srv  log_server_r: request: GET /props 127.0.0.1 200\n",
      "srv  log_server_r: request: GET /props 127.0.0.1 200\n",
      "srv  log_server_r: request: GET /props 127.0.0.1 200\n",
      "srv  update_slots: all slots are idle\n",
      "srv  log_server_r: request: GET /slots 127.0.0.1 200\n",
      "srv  log_server_r: request: GET /props 127.0.0.1 200\n",
      "srv  log_server_r: request: GET /props 127.0.0.1 200\n",
      "srv  params_from_: Chat format: Content-only\n",
      "slot get_availabl: id  3 | task -1 | selected slot by LRU, t_last = -1\n",
      "slot launch_slot_: id  3 | task -1 | sampler chain: logits -> logit-bias -> penalties -> dry -> top-n-sigma -> top-k -> typical -> top-p -> min-p -> xtc -> temp-ext -> dist \n",
      "slot launch_slot_: id  3 | task 1 | processing task\n",
      "slot update_slots: id  3 | task 1 | new prompt, n_ctx_slot = 4096, n_keep = 0, task.n_tokens = 17\n",
      "slot update_slots: id  3 | task 1 | n_tokens = 0, memory_seq_rm [0, end)\n",
      "slot update_slots: id  3 | task 1 | prompt processing progress, n_tokens = 17, batch.n_tokens = 17, progress = 1.000000\n",
      "slot update_slots: id  3 | task 1 | prompt done, n_tokens = 17, batch.n_tokens = 17\n",
      "srv  log_server_r: request: GET /props 127.0.0.1 200\n",
      "srv  log_server_r: request: GET /slots 127.0.0.1 200\n",
      "srv  log_server_r: request: GET /slots 127.0.0.1 200\n",
      "slot print_timing: id  3 | task 1 | \n",
      "prompt eval time =     230.02 ms /    17 tokens (   13.53 ms per token,    73.91 tokens per second)\n",
      "       eval time =  102383.24 ms /  1837 tokens (   55.73 ms per token,    17.94 tokens per second)\n",
      "      total time =  102613.26 ms /  1854 tokens\n",
      "slot      release: id  3 | task 1 | stop processing: n_tokens = 1853, truncated = 0\n",
      "srv  update_slots: all slots are idle\n",
      "srv  log_server_r: request: POST /v1/chat/completions 127.0.0.1 200\n",
      "^C\n",
      "Received second interrupt, terminating immediately.\n"
     ]
    }
   ],
   "source": [
    "!llama-server -hf Qwen/Qwen3-8B-GGUF:Q4_K_M --port 8080"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "682f138b",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "anlp",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.18"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
