mirror of
				https://github.com/ggml-org/llama.cpp.git
				synced 2025-10-31 08:51:55 +00:00 
			
		
		
		
	model-conversion : add embedding prompt file support (#15871)
This commit adds support for passing a prompt file to the model conversion targets/scripts. It also updates the logits.cpp to print out embedding information in the same format as when running the original embedding model. The motivation for this is that it allows us to pass files of different sizes when running the converted models and validating the logits. This can be particularly important when testing the sliding window functionality of models where the sequence length needs to exceed a certain number of tokens to trigger the sliding window logic.
This commit is contained in:
		| @@ -2,8 +2,27 @@ | ||||
|  | ||||
| set -e | ||||
|  | ||||
| # First try command line argument, then environment variable, then file | ||||
| CONVERTED_MODEL="${1:-"$CONVERTED_EMBEDDING_MODEL"}" | ||||
| # Parse command line arguments | ||||
| CONVERTED_MODEL="" | ||||
| PROMPTS_FILE="" | ||||
|  | ||||
| while [[ $# -gt 0 ]]; do | ||||
|     case $1 in | ||||
|         -p|--prompts-file) | ||||
|             PROMPTS_FILE="$2" | ||||
|             shift 2 | ||||
|             ;; | ||||
|         *) | ||||
|             if [ -z "$CONVERTED_MODEL" ]; then | ||||
|                 CONVERTED_MODEL="$1" | ||||
|             fi | ||||
|             shift | ||||
|             ;; | ||||
|     esac | ||||
| done | ||||
|  | ||||
| # First try command line argument, then environment variable | ||||
| CONVERTED_MODEL="${CONVERTED_MODEL:-"$CONVERTED_EMBEDDING_MODEL"}" | ||||
|  | ||||
| # Final check if we have a model path | ||||
| if [ -z "$CONVERTED_MODEL" ]; then | ||||
| @@ -13,8 +32,19 @@ if [ -z "$CONVERTED_MODEL" ]; then | ||||
|     exit 1 | ||||
| fi | ||||
|  | ||||
| # Read prompt from file or use default | ||||
| if [ -n "$PROMPTS_FILE" ]; then | ||||
|     if [ ! -f "$PROMPTS_FILE" ]; then | ||||
|         echo "Error: Prompts file '$PROMPTS_FILE' not found" >&2 | ||||
|         exit 1 | ||||
|     fi | ||||
|     PROMPT=$(cat "$PROMPTS_FILE") | ||||
| else | ||||
|     PROMPT="Hello world today" | ||||
| fi | ||||
|  | ||||
| echo $CONVERTED_MODEL | ||||
|  | ||||
| cmake --build ../../build --target llama-logits -j8 | ||||
|  | ||||
| ../../build/bin/llama-logits -m "$CONVERTED_MODEL" -embd-mode "Hello world today" | ||||
| # TODO: update logits.cpp to accept a --file/-f option for the prompt | ||||
| ../../build/bin/llama-logits -m "$CONVERTED_MODEL" -embd-mode "$PROMPT" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Daniel Bevenius
					Daniel Bevenius