Skip to content

Commit fb7bb4c

Browse files
ggerganovhodlen
authored andcommitted
examples : add few-shot translation example (ggml-org#4783)
1 parent a9c1467 commit fb7bb4c

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

examples/base-translate.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
#
3+
# Few-shot translation example.
4+
# Requires a base model (i.e. no fine-tuned or instruct models).
5+
#
6+
# Usage:
7+
#
8+
# cd llama.cpp
9+
# make -j
10+
#
11+
# ./examples/base-translate.sh <model-base> "<text>"
12+
#
13+
14+
if [ $# -ne 2 ]; then
15+
echo "Usage: ./base-translate.sh <model-base> \"<text>\""
16+
exit 1
17+
fi
18+
19+
ftmp="__llama.cpp_example_tmp__.txt"
20+
trap "rm -f $ftmp" EXIT
21+
22+
echo "Translate from English to French:
23+
24+
===
25+
26+
sea otter, peppermint, plush girafe:
27+
28+
sea otter => loutre de mer
29+
peppermint => menthe poivrée
30+
plush girafe => girafe peluche
31+
32+
===
33+
34+
violin
35+
36+
violin => violon
37+
38+
===
39+
40+
phone, computer, mouse, keyboard:
41+
42+
phone => téléphone
43+
computer => ordinateur
44+
mouse => souris
45+
keyboard => clavier
46+
47+
===
48+
" > $ftmp
49+
50+
echo "$2
51+
" >> $ftmp
52+
53+
model=$1
54+
55+
# generate the most likely continuation, run on the CPU until the string "===" is found
56+
./main -m $model -f $ftmp -n 64 --temp 0 --repeat-penalty 1.0 --no-penalize-nl -ngl 0 -r "==="

0 commit comments

Comments
 (0)