llama.cpp/examples
Xiao-Yong Jin 6e7cca4047
llama : add custom RoPE (#2054)
* Implement customizable RoPE

The original RoPE has pre-defined parameters

theta_i = 10000^(−2(i−1)/d), for i in [1, 2, ..., d/2]

Our customizable RoPE, ggml_rope_custom_inplace, uses

theta_i = scale * base^(−2(i−1)/d), for i in [1, 2, ..., d/2]

with the default matches the original

scale = 1.0
base = 10000

The new command line arguments
--rope-freq-base
--rope-freq-scale
set the two new RoPE parameter.

Recent researches show changing these two parameters extends the context limit with minimal loss.

1. Extending Context to 8K
   kaiokendev
   https://kaiokendev.github.io/til#extending-context-to-8k

2. Extending Context Window of Large Language Models via Positional Interpolation
   Shouyuan Chen, Sherman Wong, Liangjian Chen, Yuandong Tian
   https://arxiv.org/abs/2306.15595

3. NTK-Aware Scaled RoPE allows LLaMA models to have extended (8k+) context size without any fine-tuning and minimal perplexity degradation.
   https://www.reddit.com/user/bloc97
   https://www.reddit.com/r/LocalLLaMA/comments/14lz7j5/ntkaware_scaled_rope_allows_llama_models_to_have/

For the bold, try adding the following command line parameters to your favorite model:
-c 16384 --rope-freq-base 80000 --rope-freq-scale 0.5

* ggml-metal: fix custom rope

* common: fix argument names in help

* llama: increase MEM_REQ_EVAL for MODEL_3B

It avoids crashing for quantized weights on CPU.
Better ways to calculate the required buffer size would be better.

* llama: make MEM_REQ_EVAL depend on n_ctx

* server: use proper Content-Type in curl examples

Without the header Content-Type: application/json, curl will POST with
Content-Type: application/x-www-form-urlencoded

Though our simple server doesn't care, the httplib.h used has a limit
with CPPHTTPLIB_FORM_URL_ENCODED_PAYLOAD_MAX_LENGTH 8192

With Content-Type: application/json, we can send large json data.

* style : minor fixes, mostly indentations

* ggml : fix asserts

---------

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
2023-07-15 13:34:16 +03:00
..
baby-llama ggml : change ggml_graph_compute() API to not require context (#1999) 2023-07-07 19:24:01 +03:00
benchmark ggml : change ggml_graph_compute() API to not require context (#1999) 2023-07-07 19:24:01 +03:00
embd-input examples : fixed path typos in embd-input (#2214) 2023-07-14 21:40:05 +03:00
embedding mpi : add support for distributed inference via MPI (#2099) 2023-07-10 18:49:56 +03:00
jeopardy hooks : setting up flake8 and pre-commit hooks (#1681) 2023-06-17 13:32:48 +03:00
main llama : add custom RoPE (#2054) 2023-07-15 13:34:16 +03:00
metal ggml : change ggml_graph_compute() API to not require context (#1999) 2023-07-07 19:24:01 +03:00
perplexity mpi : add support for distributed inference via MPI (#2099) 2023-07-10 18:49:56 +03:00
quantize mpi : add support for distributed inference via MPI (#2099) 2023-07-10 18:49:56 +03:00
quantize-stats ggml : generalize quantize_fns for simpler FP16 handling (#1237) 2023-07-05 19:13:06 +03:00
save-load-state llama : make model stateless and context stateful (llama_state) (#1797) 2023-06-24 11:47:58 +03:00
server llama : add custom RoPE (#2054) 2023-07-15 13:34:16 +03:00
simple mpi : add support for distributed inference via MPI (#2099) 2023-07-10 18:49:56 +03:00
train-text-from-scratch ggml : remove src0 and src1 from ggml_tensor and rename opt to src (#2178) 2023-07-11 19:31:10 +03:00
alpaca.sh alpaca.sh : update model file name (#2074) 2023-07-06 19:17:50 +03:00
chat-13B.bat Create chat-13B.bat (#592) 2023-03-29 20:21:09 +03:00
chat-13B.sh examples : read chat prompts from a template file (#1196) 2023-05-03 20:58:11 +03:00
chat-persistent.sh chat-persistent.sh : use bracket expressions in grep (#1564) 2023-05-24 09:16:22 +03:00
chat-vicuna.sh examples : add chat-vicuna.sh (#1854) 2023-06-15 21:05:53 +03:00
chat.sh If n_predict == -1, generate forever 2023-03-25 21:51:41 +02:00
CMakeLists.txt llama : support input embeddings directly (#1910) 2023-06-28 18:53:37 +03:00
common.cpp llama : add custom RoPE (#2054) 2023-07-15 13:34:16 +03:00
common.h llama : add custom RoPE (#2054) 2023-07-15 13:34:16 +03:00
gpt4all.sh examples : add -n to alpaca and gpt4all scripts (#706) 2023-04-13 16:03:39 +03:00
Miku.sh examples : various prompt and example fixes (#1298) 2023-05-03 18:26:47 +03:00
reason-act.sh add example of re-act pattern (#583) 2023-03-29 10:10:24 -05:00