llama.cpp/examples/infill
Xuan Son Nguyen 1b9ae5189c
common : refactor arg parser (#9308)
* (wip) argparser v3

* migrated

* add test

* handle env

* fix linux build

* add export-docs example

* fix build (2)

* skip build test-arg-parser on windows

* update server docs

* bring back missing --alias

* bring back --n-predict

* clarify test-arg-parser

* small correction

* add comments

* fix args with 2 values

* refine example-specific args

* no more lamba capture

Co-authored-by: slaren@users.noreply.github.com

* params.sparams

* optimize more

* export-docs --> gen-docs
2024-09-07 20:43:51 +02:00
..
CMakeLists.txt build: rename main → llama-cli, server → llama-server, llava-cli → llama-llava-cli, etc... (#7809) 2024-06-13 00:41:52 +01:00
infill.cpp common : refactor arg parser (#9308) 2024-09-07 20:43:51 +02:00
README.md Add SPM infill support (#8016) 2024-06-28 12:53:43 +02:00

llama.cpp/example/infill

This example shows how to use the infill mode with Code Llama models supporting infill mode. Currently the 7B and 13B models support infill mode.

Infill supports most of the options available in the main example.

For further information have a look at the main README.md in llama.cpp/example/main/README.md

Common Options

In this section, we cover the most commonly used options for running the infill program with the LLaMA models:

  • -m FNAME, --model FNAME: Specify the path to the LLaMA model file (e.g., models/7B/ggml-model.bin).
  • -i, --interactive: Run the program in interactive mode, allowing you to provide input directly and receive real-time responses.
  • -n N, --n-predict N: Set the number of tokens to predict when generating text. Adjusting this value can influence the length of the generated text.
  • -c N, --ctx-size N: Set the size of the prompt context. The default is 512, but LLaMA models were built with a context of 2048, which will provide better results for longer input/inference.
  • --spm-infill: Use Suffix/Prefix/Middle pattern for infill (instead of Prefix/Suffix/Middle) as some models prefer this.

Input Prompts

The infill program provides several ways to interact with the LLaMA models using input prompts:

  • --in-prefix PROMPT_BEFORE_CURSOR: Provide the prefix directly as a command-line option.
  • --in-suffix PROMPT_AFTER_CURSOR: Provide the suffix directly as a command-line option.
  • --interactive-first: Run the program in interactive mode and wait for input right away. (More on this below.)

Interaction

The infill program offers a seamless way to interact with LLaMA models, allowing users to receive real-time infill suggestions. The interactive mode can be triggered using --interactive, and --interactive-first

Interaction Options

  • -i, --interactive: Run the program in interactive mode, allowing users to get real time code suggestions from model.
  • --interactive-first: Run the program in interactive mode and immediately wait for user input before starting the text generation.
  • --color: Enable colorized output to differentiate visually distinguishing between prompts, user input, and generated text.

Example

Download a model that supports infill, for example CodeLlama:

scripts/hf.sh --repo TheBloke/CodeLlama-13B-GGUF --file codellama-13b.Q5_K_S.gguf --outdir models
./llama-infill -t 10 -ngl 0 -m models/codellama-13b.Q5_K_S.gguf -c 4096 --temp 0.7 --repeat_penalty 1.1 -n 20 --in-prefix "def helloworld():\n    print(\"hell" --in-suffix "\n   print(\"goodbye world\")\n    "