-
-
Save zhanxw/5b71364bf10bb4c32eb309a046eec09e to your computer and use it in GitHub Desktop.
Revisions
-
zhanxw revised this gist
May 31, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -96,7 +96,7 @@ while IFS= read -r layer; do ;; params) PARAMS_JSON="$(cat "$BLOB_FILE_PATH")" printf "%s" "$(jq -r 'to_entries[] | "PARAMETER \(.key) \"\(.value | if type == "array" then .[] else . end)\""' <<<"$PARAMS_JSON")" >>"$EXPORT_MODEL_FILE_PATH" ;; *) TYPE_NAME="$(echo "$BLOB_TYPE_NAME" | tr '[:lower:]' '[:upper:]')" -
supersonictw revised this gist
Nov 27, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/bin/bash # Ollama Model Export Script # Usage: bash ollama-export.sh vicuna:7b # SPDX-License-Identifier: MIT (https://ncurl.xyz/s/o_o6DVqIR) # https://gist.github.com/supersonictw/f6cf5e599377132fe5e180b3d495c553 # Interrupt if any error occurred -
supersonictw revised this gist
Sep 16, 2024 . 1 changed file with 20 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,19 +4,31 @@ # License: MIT (https://ncurl.xyz/s/o_o6DVqIR) # https://gist.github.com/supersonictw/f6cf5e599377132fe5e180b3d495c553 # Interrupt if any error occurred set -e # Declare echo "Ollama Model Export Script" echo "License: MIT (https://ncurl.xyz/s/o_o6DVqIR)" echo "" # OS-specific case "$OSTYPE" in linux*) HOME="$(echo ~ollama)" ;; esac # Define variables OLLAMA_HOME="${OLLAMA_HOME:="$HOME/.ollama"}" BLOBS_FILE_BASE_PATH="$OLLAMA_HOME/models/blobs" MANIFESTS_FILE_BASE_PATH="$OLLAMA_HOME/models/manifests" # Define constants SUCCESS_PREFIX="\033[1;32mSuccess:\033[0m" FAILED_PREFIX="\033[0;31mFailed:\033[0m" # Read arguments IFS='/' read -ra NAME_ARGS <<< "${1/://}" case "${#NAME_ARGS[@]}" in 4) @@ -39,30 +51,36 @@ case "${#NAME_ARGS[@]}" in ;; esac # Define variables MANIFESTS_REGISTRY_NAME="${MANIFESTS_REGISTRY_NAME:="registry.ollama.ai"}" MANIFESTS_LIBRARY_NAME="${MANIFESTS_LIBRARY_NAME:="library"}" MANIFESTS_MODEL_NAME="${MANIFESTS_MODEL_NAME:="vicuna"}" MANIFESTS_PARAMS_NAME="${MANIFESTS_PARAMS_NAME:="latest"}" # Echo the model full name MODEL_FULL_NAME="$MANIFESTS_MODEL_NAME:$MANIFESTS_PARAMS_NAME" echo "Exporting model \"$MODEL_FULL_NAME\"..." echo "" # Make sure manifests exist MANIFESTS_FILE_PATH="$MANIFESTS_FILE_BASE_PATH/$MANIFESTS_REGISTRY_NAME/$MANIFESTS_LIBRARY_NAME/$MANIFESTS_MODEL_NAME/$MANIFESTS_PARAMS_NAME" if [ ! -f "$MANIFESTS_FILE_PATH" ]; then echo -e "$FAILED_PREFIX \"$MANIFESTS_FILE_PATH\" not exists, the model \"$MODEL_FULL_NAME\" you requested is not found." exit 1 fi # Make sure dist not exist EXPORT_DST_BASE_PATH="${EXPORT_DST_BASE_PATH:="$PWD/${MODEL_FULL_NAME/:/-}"}" if [ -d "$EXPORT_DST_BASE_PATH" ]; then echo -e "$FAILED_PREFIX \"$EXPORT_DST_BASE_PATH\" already exists, exits for preventing from unexpected operations." exit 1 fi # Create dist directory mkdir -p "$EXPORT_DST_BASE_PATH" printf "%s" "$MANIFESTS_REGISTRY_NAME/$MANIFESTS_LIBRARY_NAME/$MANIFESTS_MODEL_NAME:$MANIFESTS_PARAMS_NAME" >"$EXPORT_DST_BASE_PATH/source.txt" # Read manifests and handle them while IFS= read -r layer; do BLOB_FILE_NAME="${layer/:/-}" BLOB_FILE_PATH="$BLOBS_FILE_BASE_PATH/$BLOB_FILE_NAME" @@ -87,4 +105,6 @@ while IFS= read -r layer; do ;; esac done < <(jq -r '.layers[].digest' "${MANIFESTS_FILE_PATH}") # Echo success message echo -e "$SUCCESS_PREFIX Model \"$MODEL_FULL_NAME\" has been exported to \"$EXPORT_DST_BASE_PATH\"!" -
supersonictw revised this gist
Sep 16, 2024 . 1 changed file with 6 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ set -e echo "Ollama Model Export Script" echo "License: MIT (https://ncurl.xyz/s/o_o6DVqIR)" echo "" OLLAMA_HOME="${OLLAMA_HOME:="$HOME/.ollama"}" @@ -61,7 +61,7 @@ if [ -d "$EXPORT_DST_BASE_PATH" ]; then fi mkdir -p "$EXPORT_DST_BASE_PATH" printf "%s" "$MANIFESTS_REGISTRY_NAME/$MANIFESTS_LIBRARY_NAME/$MANIFESTS_MODEL_NAME:$MANIFESTS_PARAMS_NAME" >"$EXPORT_DST_BASE_PATH/source.txt" while IFS= read -r layer; do BLOB_FILE_NAME="${layer/:/-}" @@ -74,15 +74,16 @@ while IFS= read -r layer; do case "$BLOB_TYPE_NAME" in model) cp "$BLOB_FILE_PATH" "$EXPORT_MODEL_BIN_PATH" printf "%s\n" "FROM ./model.bin" >>"$EXPORT_MODEL_FILE_PATH" ;; params) PARAMS_JSON="$(cat "$BLOB_FILE_PATH")" printf "%s" "$(jq -r 'keys[] as $key | .[$key][] | "PARAMETER \($key) \"\(.)\"" ' <<<"$PARAMS_JSON")" >>"$EXPORT_MODEL_FILE_PATH" ;; *) TYPE_NAME="$(echo "$BLOB_TYPE_NAME" | tr '[:lower:]' '[:upper:]')" FILE_CONTENT="$(cat "$BLOB_FILE_PATH")" printf "%s\n" "$TYPE_NAME \"\"\"$FILE_CONTENT\"\"\"" >>"$EXPORT_MODEL_FILE_PATH" ;; esac done < <(jq -r '.layers[].digest' "${MANIFESTS_FILE_PATH}") -
supersonictw revised this gist
Aug 25, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/bin/bash # Ollama Model Export Script # Usage: bash ollama-export.sh vicuna:7b # License: MIT (https://ncurl.xyz/s/o_o6DVqIR) # https://gist.github.com/supersonictw/f6cf5e599377132fe5e180b3d495c553 set -e -
supersonictw revised this gist
Aug 25, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/bin/bash # Ollama Model Export Script # Usage: bash ollama-export.sh vicuna:7b # License: MIT (https://ncurl.xyz/s/wRbrv4qSR) # https://gist.github.com/supersonictw/f6cf5e599377132fe5e180b3d495c553 set -e -
supersonictw revised this gist
Jun 11, 2024 . 1 changed file with 1 addition and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -63,19 +63,8 @@ fi mkdir -p "$EXPORT_DST_BASE_PATH" printf "$MANIFESTS_REGISTRY_NAME/$MANIFESTS_LIBRARY_NAME/$MANIFESTS_MODEL_NAME:$MANIFESTS_PARAMS_NAME" >"$EXPORT_DST_BASE_PATH/source.txt" while IFS= read -r layer; do BLOB_FILE_NAME="${layer/:/-}" BLOB_FILE_PATH="$BLOBS_FILE_BASE_PATH/$BLOB_FILE_NAME" BLOB_TYPE_NAME=$(jq -r --arg layer "$layer" '.layers[] | select(.digest == $layer) | .mediaType' "$MANIFESTS_FILE_PATH" | sed 's|.*\.ollama\.image\.\(.*\)|\1|') -
supersonictw revised this gist
Apr 26, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -61,7 +61,7 @@ if [ -d "$EXPORT_DST_BASE_PATH" ]; then fi mkdir -p "$EXPORT_DST_BASE_PATH" printf "$MANIFESTS_REGISTRY_NAME/$MANIFESTS_LIBRARY_NAME/$MANIFESTS_MODEL_NAME:$MANIFESTS_PARAMS_NAME" >"$EXPORT_DST_BASE_PATH/source.txt" FETCH_BLOB_FILE_NAME() { case "$OSTYPE" in -
supersonictw revised this gist
Apr 26, 2024 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -85,15 +85,15 @@ while IFS= read -r layer; do case "$BLOB_TYPE_NAME" in model) cp "$BLOB_FILE_PATH" "$EXPORT_MODEL_BIN_PATH" printf "FROM ./model.bin\n" >>"$EXPORT_MODEL_FILE_PATH" ;; params) PARAMS_JSON="$(cat "$BLOB_FILE_PATH")" printf "$(jq -r 'keys[] as $key | .[$key][] | "PARAMETER \($key) \"\(.)\"" ' <<<"$PARAMS_JSON")" >>"$EXPORT_MODEL_FILE_PATH" ;; *) TYPE_NAME="$(echo "$BLOB_TYPE_NAME" | tr '[:lower:]' '[:upper:]')" printf "$TYPE_NAME \"\"\"$(cat "$BLOB_FILE_PATH")\"\"\"\n" >>"$EXPORT_MODEL_FILE_PATH" ;; esac done < <(jq -r '.layers[].digest' "${MANIFESTS_FILE_PATH}") -
supersonictw revised this gist
Apr 26, 2024 . 1 changed file with 5 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,7 @@ MANIFESTS_FILE_BASE_PATH="$OLLAMA_HOME/models/manifests" SUCCESS_PREFIX="\033[1;32mSuccess:\033[0m" FAILED_PREFIX="\033[0;31mFailed:\033[0m" IFS='/' read -ra NAME_ARGS <<< "${1/://}" case "${#NAME_ARGS[@]}" in 4) MANIFESTS_REGISTRY_NAME="${NAME_ARGS[0]}" @@ -54,7 +54,7 @@ if [ ! -f "$MANIFESTS_FILE_PATH" ]; then exit 1 fi EXPORT_DST_BASE_PATH="${EXPORT_DST_BASE_PATH:="$PWD/${MODEL_FULL_NAME/:/-}"}" if [ -d "$EXPORT_DST_BASE_PATH" ]; then echo -e "$FAILED_PREFIX \"$EXPORT_DST_BASE_PATH\" already exists, exits for preventing from unexpected operations." exit 1 @@ -66,7 +66,7 @@ echo "$MANIFESTS_REGISTRY_NAME/$MANIFESTS_LIBRARY_NAME/$MANIFESTS_MODEL_NAME:$MA FETCH_BLOB_FILE_NAME() { case "$OSTYPE" in darwin*) echo "${1/:/-}" ;; *) echo "$1" @@ -92,7 +92,8 @@ while IFS= read -r layer; do printf "$(jq -r 'keys[] as $key | .[$key][] | "PARAMETER \($key) \"\(.)\"" ' <<<"$PARAMS_JSON")" >>"$EXPORT_MODEL_FILE_PATH" ;; *) TYPE_NAME="$(echo "$BLOB_TYPE_NAME" | tr '[:lower:]' '[:upper:]')" echo "$TYPE_NAME """$(cat "$BLOB_FILE_PATH")"""" >>"$EXPORT_MODEL_FILE_PATH" ;; esac done < <(jq -r '.layers[].digest' "${MANIFESTS_FILE_PATH}") -
supersonictw revised this gist
Apr 26, 2024 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,8 +18,6 @@ SUCCESS_PREFIX="\033[1;32mSuccess:\033[0m" FAILED_PREFIX="\033[0;31mFailed:\033[0m" readarray -td\/ NAME_ARGS < <(printf "%s" "${1/\:/\/}") case "${#NAME_ARGS[@]}" in 4) MANIFESTS_REGISTRY_NAME="${NAME_ARGS[0]}" -
supersonictw revised this gist
Apr 26, 2024 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -86,7 +86,6 @@ while IFS= read -r layer; do case "$BLOB_TYPE_NAME" in model) cp "$BLOB_FILE_PATH" "$EXPORT_MODEL_BIN_PATH" echo "FROM ./model.bin" >>"$EXPORT_MODEL_FILE_PATH" ;; -
supersonictw revised this gist
Apr 26, 2024 . 1 changed file with 21 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,17 +46,16 @@ MANIFESTS_LIBRARY_NAME="${MANIFESTS_LIBRARY_NAME:="library"}" MANIFESTS_MODEL_NAME="${MANIFESTS_MODEL_NAME:="vicuna"}" MANIFESTS_PARAMS_NAME="${MANIFESTS_PARAMS_NAME:="latest"}" MODEL_FULL_NAME="$MANIFESTS_MODEL_NAME:$MANIFESTS_PARAMS_NAME" echo "Exporting model \"$MODEL_FULL_NAME\"..." echo "" MANIFESTS_FILE_PATH="$MANIFESTS_FILE_BASE_PATH/$MANIFESTS_REGISTRY_NAME/$MANIFESTS_LIBRARY_NAME/$MANIFESTS_MODEL_NAME/$MANIFESTS_PARAMS_NAME" if [ ! -f "$MANIFESTS_FILE_PATH" ]; then echo -e "$FAILED_PREFIX \"$MANIFESTS_FILE_PATH\" not exists, the model \"$MODEL_FULL_NAME\" you requested is not found." exit 1 fi EXPORT_DST_BASE_PATH="${EXPORT_DST_BASE_PATH:="$PWD/${MODEL_FULL_NAME/\:/\-}"}" if [ -d "$EXPORT_DST_BASE_PATH" ]; then echo -e "$FAILED_PREFIX \"$EXPORT_DST_BASE_PATH\" already exists, exits for preventing from unexpected operations." @@ -66,8 +65,19 @@ fi mkdir -p "$EXPORT_DST_BASE_PATH" echo "$MANIFESTS_REGISTRY_NAME/$MANIFESTS_LIBRARY_NAME/$MANIFESTS_MODEL_NAME:$MANIFESTS_PARAMS_NAME" >"$EXPORT_DST_BASE_PATH/source.txt" FETCH_BLOB_FILE_NAME() { case "$OSTYPE" in darwin*) echo "${1/\:/\-}" ;; *) echo "$1" ;; esac } while IFS= read -r layer; do BLOB_FILE_NAME=$(FETCH_BLOB_FILE_NAME "$layer") BLOB_FILE_PATH="$BLOBS_FILE_BASE_PATH/$BLOB_FILE_NAME" BLOB_TYPE_NAME=$(jq -r --arg layer "$layer" '.layers[] | select(.digest == $layer) | .mediaType' "$MANIFESTS_FILE_PATH" | sed 's|.*\.ollama\.image\.\(.*\)|\1|') @@ -76,14 +86,16 @@ while IFS= read -r layer; do case "$BLOB_TYPE_NAME" in model) echo "$BLOB_FILE_NAME" cp "$BLOB_FILE_PATH" "$EXPORT_MODEL_BIN_PATH" echo "FROM ./model.bin" >>"$EXPORT_MODEL_FILE_PATH" ;; params) PARAMS_JSON="$(cat "$BLOB_FILE_PATH")" printf "$(jq -r 'keys[] as $key | .[$key][] | "PARAMETER \($key) \"\(.)\"" ' <<<"$PARAMS_JSON")" >>"$EXPORT_MODEL_FILE_PATH" ;; *) echo "${BLOB_TYPE_NAME^^} \"\"\"$(cat "$BLOB_FILE_PATH")\"\"\"" >>"$EXPORT_MODEL_FILE_PATH" ;; esac done < <(jq -r '.layers[].digest' "${MANIFESTS_FILE_PATH}") -
supersonictw revised this gist
Apr 25, 2024 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -77,7 +77,10 @@ while IFS= read -r layer; do case "$BLOB_TYPE_NAME" in model) cp "$BLOB_FILE_PATH" "$EXPORT_MODEL_BIN_PATH" echo "FROM ./model.bin" >>"$EXPORT_MODEL_FILE_PATH" ;; params) echo "PARAMETER $(cat "$BLOB_FILE_PATH")" >>"$EXPORT_MODEL_FILE_PATH" ;; *) echo "${BLOB_TYPE_NAME^^} $(cat "$BLOB_FILE_PATH")" >>"$EXPORT_MODEL_FILE_PATH" -
supersonictw revised this gist
Apr 25, 2024 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -62,7 +62,9 @@ if [ -d "$EXPORT_DST_BASE_PATH" ]; then echo -e "$FAILED_PREFIX \"$EXPORT_DST_BASE_PATH\" already exists, exits for preventing from unexpected operations." exit 1 fi mkdir -p "$EXPORT_DST_BASE_PATH" echo "$MANIFESTS_REGISTRY_NAME/$MANIFESTS_LIBRARY_NAME/$MANIFESTS_MODEL_NAME:$MANIFESTS_PARAMS_NAME" >"$EXPORT_DST_BASE_PATH/source.txt" while IFS= read -r layer; do BLOB_FILE_NAME="$layer" -
supersonictw revised this gist
Apr 25, 2024 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -57,7 +57,7 @@ MODEL_FULL_NAME="$MANIFESTS_MODEL_NAME:$MANIFESTS_PARAMS_NAME" echo "Exporting model \"$MODEL_FULL_NAME\"..." echo "" EXPORT_DST_BASE_PATH="${EXPORT_DST_BASE_PATH:="$PWD/${MODEL_FULL_NAME/\:/\-}"}" if [ -d "$EXPORT_DST_BASE_PATH" ]; then echo -e "$FAILED_PREFIX \"$EXPORT_DST_BASE_PATH\" already exists, exits for preventing from unexpected operations." exit 1 @@ -70,12 +70,12 @@ while IFS= read -r layer; do BLOB_TYPE_NAME=$(jq -r --arg layer "$layer" '.layers[] | select(.digest == $layer) | .mediaType' "$MANIFESTS_FILE_PATH" | sed 's|.*\.ollama\.image\.\(.*\)|\1|') EXPORT_MODEL_FILE_PATH="$EXPORT_DST_BASE_PATH/Modelfile" EXPORT_MODEL_BIN_PATH="$EXPORT_DST_BASE_PATH/model.bin" case "$BLOB_TYPE_NAME" in model) cp "$BLOB_FILE_PATH" "$EXPORT_MODEL_BIN_PATH" echo "MODEL ./model.bin" >>"$EXPORT_MODEL_FILE_PATH" ;; *) echo "${BLOB_TYPE_NAME^^} $(cat "$BLOB_FILE_PATH")" >>"$EXPORT_MODEL_FILE_PATH" -
supersonictw revised this gist
Apr 25, 2024 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ #!/bin/bash # Ollama Model Export Script # Usage: bash ollama-export.sh vicuna:7b # License: MIT (https://ncurl.xyz/s/RD0Yl5fSg) # https://gist.github.com/supersonictw/f6cf5e599377132fe5e180b3d495c553 -
supersonictw revised this gist
Apr 25, 2024 . No changes.There are no files selected for viewing
-
supersonictw revised this gist
Apr 25, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -43,7 +43,7 @@ esac MANIFESTS_REGISTRY_NAME="${MANIFESTS_REGISTRY_NAME:="registry.ollama.ai"}" MANIFESTS_LIBRARY_NAME="${MANIFESTS_LIBRARY_NAME:="library"}" MANIFESTS_MODEL_NAME="${MANIFESTS_MODEL_NAME:="vicuna"}" MANIFESTS_PARAMS_NAME="${MANIFESTS_PARAMS_NAME:="latest"}" MANIFESTS_FILE_PATH="$MANIFESTS_FILE_BASE_PATH/$MANIFESTS_REGISTRY_NAME/$MANIFESTS_LIBRARY_NAME/$MANIFESTS_MODEL_NAME/$MANIFESTS_PARAMS_NAME" echo $MANIFESTS_FILE_PATH -
supersonictw revised this gist
Apr 25, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -43,7 +43,7 @@ esac MANIFESTS_REGISTRY_NAME="${MANIFESTS_REGISTRY_NAME:="registry.ollama.ai"}" MANIFESTS_LIBRARY_NAME="${MANIFESTS_LIBRARY_NAME:="library"}" MANIFESTS_MODEL_NAME="${MANIFESTS_MODEL_NAME:="vicuna"}" MANIFESTS_PARAMS_NAME="${MANIFESTS_PARAMS_NAME:=""}" MANIFESTS_FILE_PATH="$MANIFESTS_FILE_BASE_PATH/$MANIFESTS_REGISTRY_NAME/$MANIFESTS_LIBRARY_NAME/$MANIFESTS_MODEL_NAME/$MANIFESTS_PARAMS_NAME" echo $MANIFESTS_FILE_PATH -
supersonictw revised this gist
Apr 25, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -73,7 +73,7 @@ while IFS= read -r layer; do case "$BLOB_TYPE_NAME" in model) cp "$BLOB_FILE_PATH" "$EXPORT_MODEL_GGUF_PATH" echo "MODEL ./model.gguf" >>"$EXPORT_MODEL_FILE_PATH" ;; *) -
supersonictw revised this gist
Apr 25, 2024 . 1 changed file with 9 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,9 +16,6 @@ MANIFESTS_FILE_BASE_PATH="$OLLAMA_HOME/models/manifests" SUCCESS_PREFIX="\033[1;32mSuccess:\033[0m" FAILED_PREFIX="\033[0;31mFailed:\033[0m" readarray -td\/ NAME_ARGS < <(printf "%s" "${1/\:/\/}") declare -p NAME_ARGS >/dev/null @@ -43,10 +40,10 @@ case "${#NAME_ARGS[@]}" in ;; esac MANIFESTS_REGISTRY_NAME="${MANIFESTS_REGISTRY_NAME:="registry.ollama.ai"}" MANIFESTS_LIBRARY_NAME="${MANIFESTS_LIBRARY_NAME:="library"}" MANIFESTS_MODEL_NAME="${MANIFESTS_MODEL_NAME:="vicuna"}" MANIFESTS_PARAMS_NAME="${MANIFESTS_PARAMS_NAME:="7b"}" MANIFESTS_FILE_PATH="$MANIFESTS_FILE_BASE_PATH/$MANIFESTS_REGISTRY_NAME/$MANIFESTS_LIBRARY_NAME/$MANIFESTS_MODEL_NAME/$MANIFESTS_PARAMS_NAME" echo $MANIFESTS_FILE_PATH @@ -55,9 +52,9 @@ if [ ! -f "$MANIFESTS_FILE_PATH" ]; then exit 1 fi MODEL_FULL_NAME="$MANIFESTS_MODEL_NAME:$MANIFESTS_PARAMS_NAME" echo "Exporting model \"$MODEL_FULL_NAME\"..." echo "" EXPORT_DST_BASE_PATH="${EXPORT_DST_BASE_PATH:="$PWD/$MODEL_FULL_NAME"}" if [ -d "$EXPORT_DST_BASE_PATH" ]; then @@ -76,12 +73,12 @@ while IFS= read -r layer; do case "$BLOB_TYPE_NAME" in model) #cp "$BLOB_FILE_PATH" "$EXPORT_MODEL_GGUF_PATH" echo "MODEL ./model.gguf" >>"$EXPORT_MODEL_FILE_PATH" ;; *) echo "${BLOB_TYPE_NAME^^} $(cat "$BLOB_FILE_PATH")" >>"$EXPORT_MODEL_FILE_PATH" ;; esac done < <(jq -r '.layers[].digest' "${MANIFESTS_FILE_PATH}") echo -e "$SUCCESS_PREFIX Model \"$MODEL_FULL_NAME\" has been exported to \"$EXPORT_DST_BASE_PATH\"!" -
supersonictw revised this gist
Apr 25, 2024 . 1 changed file with 30 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,9 +19,37 @@ FAILED_PREFIX="\033[0;31mFailed:\033[0m" echo "Exporting model \"$1\"..." echo "" readarray -td\/ NAME_ARGS < <(printf "%s" "${1/\:/\/}") declare -p NAME_ARGS >/dev/null case "${#NAME_ARGS[@]}" in 4) MANIFESTS_REGISTRY_NAME="${NAME_ARGS[0]}" MANIFESTS_LIBRARY_NAME="${NAME_ARGS[1]}" MANIFESTS_MODEL_NAME="${NAME_ARGS[2]}" MANIFESTS_PARAMS_NAME="${NAME_ARGS[3]}" ;; 3) MANIFESTS_LIBRARY_NAME="${NAME_ARGS[0]}" MANIFESTS_MODEL_NAME="${NAME_ARGS[1]}" MANIFESTS_PARAMS_NAME="${NAME_ARGS[2]}" ;; 2) MANIFESTS_MODEL_NAME="${NAME_ARGS[0]}" MANIFESTS_PARAMS_NAME="${NAME_ARGS[1]}" ;; 1) MANIFESTS_MODEL_NAME="${NAME_ARGS[0]}" ;; esac MANIFESTS_REGISTRY_NAME=${MANIFESTS_REGISTRY_NAME:="registry.ollama.ai"} MANIFESTS_LIBRARY_NAME=${MANIFESTS_LIBRARY_NAME:="library"} MANIFESTS_MODEL_NAME=${MANIFESTS_MODEL_NAME:="vicuna"} MANIFESTS_PARAMS_NAME=${MANIFESTS_PARAMS_NAME:="7b"} MANIFESTS_FILE_PATH="$MANIFESTS_FILE_BASE_PATH/$MANIFESTS_REGISTRY_NAME/$MANIFESTS_LIBRARY_NAME/$MANIFESTS_MODEL_NAME/$MANIFESTS_PARAMS_NAME" echo $MANIFESTS_FILE_PATH if [ ! -f "$MANIFESTS_FILE_PATH" ]; then echo -e "$FAILED_PREFIX \"$MANIFESTS_FILE_PATH\" not exists, the model \"$1\" you requested is not found." exit 1 -
supersonictw revised this gist
Apr 25, 2024 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,12 @@ #!/bin/bash # Ollama Model Export Script # License: MIT (https://ncurl.xyz/s/RD0Yl5fSg) # https://gist.github.com/supersonictw/f6cf5e599377132fe5e180b3d495c553 set -e echo "Ollama Model Export Script" echo "License: MIT (https://ncurl.xyz/s/RD0Yl5fSg)" echo "" OLLAMA_HOME="${OLLAMA_HOME:="$HOME/.ollama"}" -
supersonictw revised this gist
Apr 25, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,7 +32,7 @@ MODEL_NAME="$(basename $(dirname "$MANIFESTS_FILE_PATH"))" MODEL_VERSION="$(basename "$MANIFESTS_FILE_PATH")" MODEL_FULL_NAME="$MODEL_NAME:$MODEL_VERSION" EXPORT_DST_BASE_PATH="${EXPORT_DST_BASE_PATH:="$PWD/$MODEL_FULL_NAME"}" if [ -d "$EXPORT_DST_BASE_PATH" ]; then echo -e "$FAILED_PREFIX \"$EXPORT_DST_BASE_PATH\" already exists, exits for preventing from unexpected operations." exit 1 -
supersonictw revised this gist
Apr 25, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ echo "License: MIT (https://ncurl.xyz/s/RD0Yl5fSg)" echo "(c) 2024 SuperSonic (https://github.com/supersonictw)" echo "" OLLAMA_HOME="${OLLAMA_HOME:="$HOME/.ollama"}" BLOBS_FILE_BASE_PATH="$OLLAMA_HOME/models/blobs" MANIFESTS_FILE_BASE_PATH="$OLLAMA_HOME/models/manifests" -
supersonictw revised this gist
Apr 25, 2024 . 1 changed file with 37 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,26 +5,56 @@ set -e echo "Ollama Model Export Script" echo "License: MIT (https://ncurl.xyz/s/RD0Yl5fSg)" echo "(c) 2024 SuperSonic (https://github.com/supersonictw)" echo "" OLLAMA_HOME="$HOME/.ollama" BLOBS_FILE_BASE_PATH="$OLLAMA_HOME/models/blobs" MANIFESTS_FILE_BASE_PATH="$OLLAMA_HOME/models/manifests" SUCCESS_PREFIX="\033[1;32mSuccess:\033[0m" FAILED_PREFIX="\033[0;31mFailed:\033[0m" echo "Exporting model \"$1\"..." echo "" MANIFESTS_FILE_NAME="${1/\:/\/}" MANIFESTS_FILE_PATH="$MANIFESTS_FILE_BASE_PATH/registry.ollama.ai/library/$MANIFESTS_FILE_NAME" if [ ! -f "$MANIFESTS_FILE_PATH" ]; then echo -e "$FAILED_PREFIX \"$MANIFESTS_FILE_PATH\" not exists, the model \"$1\" you requested is not found." exit 1 fi MODEL_NAME="$(basename $(dirname "$MANIFESTS_FILE_PATH"))" MODEL_VERSION="$(basename "$MANIFESTS_FILE_PATH")" MODEL_FULL_NAME="$MODEL_NAME:$MODEL_VERSION" EXPORT_DST_BASE_PATH="$PWD/$MODEL_FULL_NAME" if [ -d "$EXPORT_DST_BASE_PATH" ]; then echo -e "$FAILED_PREFIX \"$EXPORT_DST_BASE_PATH\" already exists, exits for preventing from unexpected operations." exit 1 fi mkdir -p "$EXPORT_DST_BASE_PATH" while IFS= read -r layer; do BLOB_FILE_NAME="$layer" BLOB_FILE_PATH="$BLOBS_FILE_BASE_PATH/$BLOB_FILE_NAME" BLOB_TYPE_NAME=$(jq -r --arg layer "$layer" '.layers[] | select(.digest == $layer) | .mediaType' "$MANIFESTS_FILE_PATH" | sed 's|.*\.ollama\.image\.\(.*\)|\1|') EXPORT_MODEL_FILE_PATH="$EXPORT_DST_BASE_PATH/Modelfile" EXPORT_MODEL_GGUF_PATH="$EXPORT_DST_BASE_PATH/model.gguf" case "$BLOB_TYPE_NAME" in model) cp "$BLOB_FILE_PATH" "$EXPORT_MODEL_GGUF_PATH" echo "MODEL ./model.gguf" >>"$EXPORT_MODEL_FILE_PATH" ;; *) echo "${BLOB_TYPE_NAME^^} $(cat "$BLOB_FILE_PATH")" >>"$EXPORT_MODEL_FILE_PATH" ;; esac done < <(jq -r '.layers[].digest' "${MANIFESTS_FILE_PATH}") echo -e "$SUCCESS_PREFIX Model \"$MODEL_NAME\" has been exported to \"$EXPORT_DST_BASE_PATH\"!" -
supersonictw revised this gist
Apr 25, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #!/bin/bash # Ollama Model Export Script # License: MIT (https://ncurl.xyz/s/RD0Yl5fSg) # (c) 2024 SuperSonic (https://github.com/supersonictw) set -e -
supersonictw created this gist
Apr 25, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ #!/bin/bash # Ollama Model Export Script # License: MIT https://ncurl.xyz/s/RD0Yl5fSg) # (c) 2024 SuperSonic (https://github.com/supersonictw) set -e OLLAMA_HOME="$HOME/.ollama" BLOBS_FILE_BASE_PATH="$OLLAMA_HOME/models/blobs" MANIFESTS_FILE_BASE_PATH="$OLLAMA_HOME/models/manifests" MANIFESTS_FILE_NAME="${1/\:/\/}" MANIFESTS_FILE_PATH="$MANIFESTS_FILE_BASE_PATH/registry.ollama.ai/library/$MANIFESTS_FILE_NAME" MODEL_NAME="$(basename $(dirname "$MANIFESTS_FILE_PATH"))" MODEL_VERSION="$(basename "$MANIFESTS_FILE_PATH")" MODEL_FULL_NAME="$MODEL_NAME:$MODEL_VERSION" EXPORT_DST_BASE_PATH="$PWD/$MODEL_FULL_NAME" mkdir -p "$EXPORT_DST_BASE_PATH" while IFS= read -r layer; do FILE_TYPE_NAME=$(jq -r --arg layer "$layer" '.layers[] | select(.digest == $layer) | .mediaType' "${MANIFESTS_FILE_PATH}" | sed 's|.*\.ollama\.image\.\(.*\)|\1|') FILE_FILE_NAME="$layer" FILE_SRC_PATH="$BLOBS_FILE_BASE_PATH/$FILE_FILE_NAME" FILE_DST_PATH="$EXPORT_DST_BASE_PATH/$FILE_TYPE_NAME" cp "$FILE_SRC_PATH" "$FILE_DST_PATH" echo "\"${FILE_TYPE_NAME}\" Copied!" done < <(jq -r '.layers[].digest' "${MANIFESTS_FILE_PATH}")