base-translate.sh 1001 B

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