mirror of
				https://github.com/ggml-org/llama.cpp.git
				synced 2025-11-04 09:32:00 +00:00 
			
		
		
		
	* model-conversion : remove hardcoded /bin/bash shebangs [no ci] This commit updates the bash scripts to use env instead of using hardcoded /bin/bash in the shebang line. The motivation for this is that some systems may have bash installed in a different location, and using /usr/bin/env bash ensures that the script will use the first bash interpreter found in the user's PATH, making the scripts more portable across different environments. * model-conversion : rename script to .py [no ci] This commit renames run-casual-gen-embeddings-org.sh to run-casual-gen-embeddings-org.py to reflect its Python nature.
		
			
				
	
	
		
			49 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/env bash
 | 
						|
 | 
						|
set -e
 | 
						|
 | 
						|
CONVERTED_MODEL="${1:-"$CONVERTED_MODEL"}"
 | 
						|
QUANTIZED_TYPE="${2:-"$QUANTIZED_TYPE"}"
 | 
						|
TOKEN_EMBD_TYPE="${3:-"${TOKEN_EMBD_TYPE}"}"
 | 
						|
OUTPUT_TYPE="${4:-"${OUTPUT_TYPE}"}"
 | 
						|
QUANTIZED_MODEL=$CONVERTED_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_MODEL environment variable" >&2
 | 
						|
    exit 1
 | 
						|
fi
 | 
						|
 | 
						|
if [ -z "$QUANTIZED_TYPE" ]; then
 | 
						|
    echo "Error: QUANTIZED_TYPE is required" >&2
 | 
						|
    exit 1
 | 
						|
fi
 | 
						|
 | 
						|
echo $CONVERTED_MODEL
 | 
						|
 | 
						|
# Process the quantized model filename
 | 
						|
if [[ "$QUANTIZED_MODEL" == *.gguf ]]; then
 | 
						|
    # Remove .gguf suffix, add quantized type, then add .gguf back
 | 
						|
    BASE_NAME="${QUANTIZED_MODEL%.gguf}"
 | 
						|
    QUANTIZED_MODEL="${BASE_NAME}-${QUANTIZED_TYPE}.gguf"
 | 
						|
else
 | 
						|
    echo "Error: QUANTIZED_MODEL must end with .gguf extension" >&2
 | 
						|
    exit 1
 | 
						|
fi
 | 
						|
 | 
						|
cmake --build ../../build --target llama-quantize -j8
 | 
						|
 | 
						|
echo $TOKEN_EMBD_TYPE
 | 
						|
echo $OUTPUT_TYPE
 | 
						|
 | 
						|
CMD_ARGS=("../../build/bin/llama-quantize")
 | 
						|
[[ -n "$TOKEN_EMBD_TYPE" ]] && CMD_ARGS+=("--token-embedding-type" "$TOKEN_EMBD_TYPE")
 | 
						|
[[ -n "$OUTPUT_TYPE" ]]     && CMD_ARGS+=("--output-tensor-type" "$OUTPUT_TYPE")
 | 
						|
CMD_ARGS+=("$CONVERTED_MODEL" "$QUANTIZED_MODEL" "$QUANTIZED_TYPE")
 | 
						|
 | 
						|
"${CMD_ARGS[@]}"
 | 
						|
 | 
						|
echo "Quantized model saved to: $QUANTIZED_MODEL"
 |