forked from ggerganov/llama.cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
examples : add few-shot translation example (ggerganov#4783)
- Loading branch information
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 "===" |