From ec88c3ceeaaa037dc8a80413c566ed6d71d9e85c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Mon, 2 Mar 2026 15:40:49 +0100 Subject: [PATCH] scripts : improve get-wikitext-2.sh (#19952) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * scripts : improve get-wikitext-2.sh Switch to sh, add curl fallback, and avoid redundant downloads Signed-off-by: Adrien Gallouët * fix indent Signed-off-by: Adrien Gallouët --------- Signed-off-by: Adrien Gallouët Signed-off-by: Adrien Gallouët --- scripts/get-wikitext-2.sh | 48 ++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/scripts/get-wikitext-2.sh b/scripts/get-wikitext-2.sh index 67b0b0118b..bd03ad3526 100755 --- a/scripts/get-wikitext-2.sh +++ b/scripts/get-wikitext-2.sh @@ -1,11 +1,43 @@ -#!/usr/bin/env bash +#!/bin/sh +# vim: set ts=4 sw=4 et: -wget https://huggingface.co/datasets/ggml-org/ci/resolve/main/wikitext-2-raw-v1.zip -unzip wikitext-2-raw-v1.zip +ZIP="wikitext-2-raw-v1.zip" +FILE="wikitext-2-raw/wiki.test.raw" +URL="https://huggingface.co/datasets/ggml-org/ci/resolve/main/$ZIP" -echo "Usage:" -echo "" -echo " ./llama-perplexity -m model.gguf -f wikitext-2-raw/wiki.test.raw [other params]" -echo "" +die() { + printf "%s\n" "$@" >&2 + exit 1 +} -exit 0 +have_cmd() { + for cmd; do + command -v "$cmd" >/dev/null || return + done +} + +dl() { + [ -f "$2" ] && return + if have_cmd wget; then + wget "$1" -O "$2" + elif have_cmd curl; then + curl -L "$1" -o "$2" + else + die "Please install wget or curl" + fi +} + +have_cmd unzip || die "Please install unzip" + +if [ ! -f "$FILE" ]; then + dl "$URL" "$ZIP" || exit + unzip -o "$ZIP" || exit + rm -f -- "$ZIP" +fi + +cat <