mirror of
https://github.com/ggerganov/llama.cpp
synced 2026-03-15 19:51:26 +01:00
This commit removes the '-st` make target for running the converted embedding model. The motivation for this is that the pooling type is now part of the .gguf metdata of the model and this is used by llama-debug when running the model. So there is no need to specify the pooling type separately any more. The commit also adds an option to specify the type of normalization applied to the output embeddings when running the converted model. And the readme documentation has been updated to reflect these changes.
55 lines
1.3 KiB
Bash
Executable File
55 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
# Parse command line arguments
|
|
CONVERTED_MODEL=""
|
|
PROMPTS_FILE=""
|
|
EMBD_NORMALIZE="2"
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
-p|--prompts-file)
|
|
PROMPTS_FILE="$2"
|
|
shift 2
|
|
;;
|
|
--embd-normalize)
|
|
EMBD_NORMALIZE="$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
|
|
echo "Error: Model path must be provided either as:" >&2
|
|
echo " 1. Command line argument" >&2
|
|
echo " 2. CONVERTED_EMBEDDING_MODEL environment variable" >&2
|
|
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-debug -j8
|
|
../../build/bin/llama-debug -m "$CONVERTED_MODEL" --embedding -p "$PROMPT" --save-logits --embd-normalize $EMBD_NORMALIZE
|