translation

command
v1.38.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

README

Translation

Translate text between languages using a GGUF language model.

How it works

  1. Loads a GGUF model via inference.LoadFile
  2. Constructs a translation prompt with source and target languages
  3. Generates the translation
  4. Prints the original text and its translation

Works best with multilingual models such as Qwen 2.5, Gemma 3, or Llama 3.

Usage

go build -o translation ./examples/translation/

# English to French (default)
./translation --model path/to/model.gguf --text "Hello, world!"

# French to English
./translation --model path/to/model.gguf --text "Bonjour le monde" --source French --target English

# English to Spanish with GPU
./translation --model path/to/model.gguf --device cuda --text "Good morning" --target Spanish

Flags

Flag Default Description
--model (required) Path to GGUF model file
--device cpu Compute device: "cpu", "cuda"
--text "The quick brown fox..." Text to translate
--source English Source language
--target French Target language
--max-tokens 256 Maximum tokens to generate

Documentation

Overview

Command translation demonstrates text translation using a GGUF language model.

It translates text between languages by prompting the model with a translation instruction. Works best with multilingual models (Qwen, Gemma, Llama 3).

Usage:

go build -o translation ./examples/translation/
./translation --model path/to/model.gguf --text "Hello, world!" --target French
./translation --model path/to/model.gguf --text "Bonjour le monde" --source French --target English

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL