base-translate.sh 924 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. if [ $# -ne 2 ]; then
  14. echo "Usage: ./base-translate.sh <model-base> \"<text>\""
  15. exit 1
  16. fi
  17. ftmp="__llama.cpp_example_tmp__.txt"
  18. trap "rm -f $ftmp" EXIT
  19. echo "Translate from English to French:
  20. ===
  21. sea otter, peppermint, plush girafe:
  22. sea otter => loutre de mer
  23. peppermint => menthe poivrée
  24. plush girafe => girafe peluche
  25. ===
  26. violin
  27. violin => violon
  28. ===
  29. phone, computer, mouse, keyboard:
  30. phone => téléphone
  31. computer => ordinateur
  32. mouse => souris
  33. keyboard => clavier
  34. ===
  35. " > $ftmp
  36. echo "$2
  37. " >> $ftmp
  38. model=$1
  39. # generate the most likely continuation, run on the CPU until the string "===" is found
  40. ./main -m $model -f $ftmp -n 64 --temp 0 --repeat-penalty 1.0 --no-penalize-nl -ngl 0 -r "==="