summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgi Gerganov <ggerganov@gmail.com>2024-01-05 15:11:10 +0200
committerGitHub <noreply@github.com>2024-01-05 15:11:10 +0200
commit3681f22443d917e7328456b69c276d6927dafeec (patch)
tree611557f78a959b32f73f869cf6e9bd84bfb75bfc
parentb3a7c20b5c035250257d2b62851c379b159c899a (diff)
examples : add few-shot translation example (#4783)
-rwxr-xr-xexamples/base-translate.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/examples/base-translate.sh b/examples/base-translate.sh
new file mode 100755
index 00000000..50fba025
--- /dev/null
+++ b/examples/base-translate.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+#
+# Few-shot translation example.
+# Requires a base model (i.e. no fine-tuned or instruct models).
+#
+# Usage:
+#
+# cd llama.cpp
+# make -j
+#
+# ./examples/base-translate.sh <model-base> "<text>"
+#
+
+if [ $# -ne 2 ]; then
+ echo "Usage: ./base-translate.sh <model-base> \"<text>\""
+ exit 1
+fi
+
+ftmp="__llama.cpp_example_tmp__.txt"
+trap "rm -f $ftmp" EXIT
+
+echo "Translate from English to French:
+
+===
+
+sea otter, peppermint, plush girafe:
+
+sea otter => loutre de mer
+peppermint => menthe poivrée
+plush girafe => girafe peluche
+
+===
+
+violin
+
+violin => violon
+
+===
+
+phone, computer, mouse, keyboard:
+
+phone => téléphone
+computer => ordinateur
+mouse => souris
+keyboard => clavier
+
+===
+" > $ftmp
+
+echo "$2
+" >> $ftmp
+
+model=$1
+
+# generate the most likely continuation, run on the CPU until the string "===" is found
+./main -m $model -f $ftmp -n 64 --temp 0 --repeat-penalty 1.0 --no-penalize-nl -ngl 0 -r "==="