Skip to content

alickwong/bedrock-translate

Repository files navigation

Bedrock Translate

npm version PRs Welcome install size

This project is created for translating markdown files, I only tested for translating AWS workshops. More features will be added soon. Feel free to send a feature request here.

🔥 Roadmap

  • Support translating file name with different name pattern
  • Support using different LLM models
  • Support translating PPTX files
  • Let llm read an article before translating for improving translation accuracy
  • Fine tune the translation using few shot learning prompt
  • Add support for

👋 Getting Started

Prerequisites

  • Node 20: Install Node.js 20 Download Node.js
  • AWS credential: Install the AWS CLI, set up the AWS CLI, enable the Anthropic Haiku & Sonnet models from the AWS console and attach an IAM policy to invoke these Amazon Bedrock models (bedrock:InvokeModelWithResponseStream).

How to install

npm install -g br-translate

🧑‍💻 How to use

Languages supported

"en": "english",
"es": "spanish",
"ja": "japanese",
"fr": "french",
"ko": "korean",
"pt": "portuguese",
"de": "german",
"it": "italian",
"zh": "chinese (simplified)",
"zh-TW": "chinese (traditional)",
"uk": "ukrainian",
"pl": "polish",
"id": "indonesian",
"nl": "dutch",
"ar": "arabic"

Translate Single File

// Simplified Chinese
br-translate start --file content/sms-v2-components/all-together/index.en.md  \
                            --targetLanguageCode zh

// Spanish
br-translate start --file content/sms-v2-components/all-together/index.en.md \
                            --targetLanguageCode es

Translate Entire Directory

// Spanish
br-translate start --dir ./content/clean-up --targetLanguageCode es
     
// Simplified Chinese
br-translate start --dir ./content --targetLanguageCode zh 

🔧 Fine Tuning

If you would like to improve the translation, this package also flexible to add extra prompt and few shot learning. You may follow this guide for more details.

⚙️ Options

Options:
  -d, --dir <directory>                            Directory containing files to translate
  -f, --file <filePath>                            single file translation
  -tlc, --targetLanguageCode <targetLanguageCode>  Target language you need
  -p, --promptFilePath <promptFilePath>            [Optional] Extra prompt for translation
  -r, --referenceFilePath <referenceFilePath>      [Optional] Sample translations you want the LLM to read before translation
  -slc, --sourceLanguageCode <sourceLanguageCode>  [Optional] The language you choose to translate from
  -h, --help   

🤝 Contributors

Alick Wong
Pavlos Ioannou Katidis
Rex Law

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published