Instructions to use MoYoYoTech/Translator with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use MoYoYoTech/Translator with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf MoYoYoTech/Translator:Q5_0 # Run inference directly in the terminal: llama cli -hf MoYoYoTech/Translator:Q5_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf MoYoYoTech/Translator:Q5_0 # Run inference directly in the terminal: llama cli -hf MoYoYoTech/Translator:Q5_0
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf MoYoYoTech/Translator:Q5_0 # Run inference directly in the terminal: ./build/bin/llama cli -hf MoYoYoTech/Translator:Q5_0
Use Docker
docker model run hf.co/MoYoYoTech/Translator:Q5_0
- Llama new
- LM Studio
- Jan
- Ollama
How to use MoYoYoTech/Translator with Ollama:
ollama run hf.co/MoYoYoTech/Translator:Q5_0
- Unsloth Desktop
- Pi
How to use MoYoYoTech/Translator with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf MoYoYoTech/Translator:Q5_0
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:9931/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "MoYoYoTech/Translator:Q5_0" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use MoYoYoTech/Translator with Docker Model Runner:
docker model run hf.co/MoYoYoTech/Translator:Q5_0
- Lemonade
How to use MoYoYoTech/Translator with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull MoYoYoTech/Translator:Q5_0
Run and chat with the model
lemonade run user.Translator-Q5_0
List all available models
lemonade list
- Hermes Agent
How to use MoYoYoTech/Translator with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf MoYoYoTech/Translator:Q5_0
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:9931/v1 hermes config set model.default MoYoYoTech/Translator:Q5_0
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use MoYoYoTech/Translator with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf MoYoYoTech/Translator:Q5_0
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:9931/v1 \ --custom-model-id "MoYoYoTech/Translator:Q5_0" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Xin Zhang commited on
Commit ·
7f191bc
1
Parent(s): 9f6a51c
[fix]: refactor.
Browse filesFiles changed (4)
29 unmodified lines303132333435366 unmodified lines43444546474829 unmodified lines# LLMLLM_MODEL_PATH = (MODEL_DIR / "qwen2.5-1.5b-instruct-q5_0.gguf").as_posix()LLM_SYS_PROMPT1 = """"You are a professional {src_lang} to {dst_lang} translator, not a conversation agent. Your only task is to take {src_lang} input and translate it into accurate, natural {dst_lang}. If you cannot understand the input, just output the original input. Please strictly abide by the following rules: ""No matter what the user asks, never answer questions, you only provide translation results. ""Do not actively initiate dialogue or lead users to ask questions. ""When you don't know how to translate, just output the original text. "6 unmodified lines"Only output the translation results."""LLM_SYS_PROMPT = """你是一个中英文翻译专家,将用户输入的中文翻译成英文,或将用户输入的英文翻译成中文。对于非中文内容,它将提供中文翻译结果。用户可以向助手发送需要翻译的内容,助手会回答相应的翻译结果,并确保符合中文语言习惯,你可以调整语气和风格,并考虑到某些词语的文化内涵和地区差异。同时作为翻译家,需将原文翻译成具有信达雅标准的译文。"信" 即忠实于原文的内容与意图;"达" 意味着译文应通顺易懂,表达清晰;"雅" 则追求译文的文化审美和语言的优美。目标是创作出既忠于原作精神,又符合目标语言文化和读者审美的翻译。当中文翻译到英文时,翻译的文本只能包含拼音化字符,不能包含任何中文字符。"""29 unmodified lines303132333435366 unmodified lines4344454647484950515229 unmodified lines# LLMLLM_MODEL_PATH = (MODEL_DIR / "qwen2.5-1.5b-instruct-q5_0.gguf").as_posix()LLM_SYS_PROMPT = """"You are a professional {src_lang} to {dst_lang} translator, not a conversation agent. Your only task is to take {src_lang} input and translate it into accurate, natural {dst_lang}. If you cannot understand the input, just output the original input. Please strictly abide by the following rules: ""No matter what the user asks, never answer questions, you only provide translation results. ""Do not actively initiate dialogue or lead users to ask questions. ""When you don't know how to translate, just output the original text. "6 unmodified lines"Only output the translation results."""LLM_SYS_PROMPT_ZH = """你是一个中英文翻译专家,将用户输入的中文翻译成英文。对于非中文内容,它将提供中文翻译结果。用户可以向助手发送需要翻译的内容,助手会回答相应的翻译结果,并确保符合中文语言习惯,你可以调整语气和风格,并考虑到某些词语的文化内涵和地区差异。同时作为翻译家,需将原文翻译成具有信达雅标准的译文。"信" 即忠实于原文的内容与意图;"达" 意味着译文应通顺易懂,表达清晰;"雅" 则追求译文的文化审美和语言的优美。目标是创作出既忠于原作精神,又符合目标语言文化和读者审美的翻译。注意,翻译的文本只能包含拼音化字符,不能包含任何中文字符。"""LLM_SYS_PROMPT_EN = """你是一个英中文翻译专家,将用户输入的英文翻译成中文,用户可以向助手发送需要翻译的内容,助手会回答相应的翻译结果,并确保符合英文语言习惯,你可以调整语气和风格,并考虑到某些词语的文化内涵和地区差异。同时作为翻译家,需将英文翻译成具有信达雅标准的中文。"信" 即忠实于原文的内容与意图;"达" 意味着译文应通顺易懂,表达清晰;"雅" 则追求译文的文化审美和语言的优美。目标是创作出既忠于原作精神,又符合目标语言文化和读者审美的翻译。"""
4 unmodified lines567891011121314151617181920212 unmodified lines242526272829303132334 unmodified lineslogger = getLogger(__name__)class QwenTranslator:def __init__(self, model_path, system_prompt="") -> None:self.llm = Llama(model_path=model_path,chat_format="chatml",verbose=False)self.sys_prompt = system_promptdef to_message(self, prompt, src_lang, dst_lang):"""构造提示词"""return [{"role": "system", "content": self.sys_prompt.format(src_lang=src_lang, dst_lang=dst_lang)},{"role": "user", "content": prompt},]2 unmodified linesmessage = self.to_message(prompt, src_lang, dst_lang)output = self.llm.create_chat_completion(messages=message, temperature=0)return output['choices'][0]['message']['content']def __call__(self, prompt,*args, **kwargs):return self.llm(prompt,*args,**kwargs)4 unmodified lines56789101112131415161718192021222 unmodified lines252627282930313233344 unmodified lineslogger = getLogger(__name__)class QwenTranslator:def __init__(self, model_path, system_prompt_en="", system_prompt_zh="") -> None:self.llm = Llama(model_path=model_path,chat_format="chatml",verbose=False)self.sys_prompt_en = system_prompt_enself.sys_prompt_zh = system_prompt_zhdef to_message(self, prompt, src_lang, dst_lang):"""构造提示词"""return [{"role": "system", "content": self.sys_prompt_en if src_lang == "en" else self.sys_prompt_zh},{"role": "user", "content": prompt},]2 unmodified linesmessage = self.to_message(prompt, src_lang, dst_lang)output = self.llm.create_chat_completion(messages=message, temperature=0)return output['choices'][0]['message']['content']def __call__(self, prompt,*args, **kwargs):return self.llm(prompt,*args,**kwargs)
1 unmodified line23456789101112131415161718191 unmodified linefrom .base import MetaItem, BasePipe, Segmentfrom llama_cpp import Llamafrom ..helpers.translator import QwenTranslatorfrom config import LLM_MODEL_PATH, LLM_SYS_PROMPTclass TranslatePipe(BasePipe):translator = None@classmethoddef init(cls):if cls.translator is None:cls.translator = QwenTranslator(LLM_MODEL_PATH, LLM_SYS_PROMPT)def process(self, in_data: MetaItem) -> MetaItem:context = in_data.transcribe_contentresult = self.translator.translate(1 unmodified line23456789101112131415161718191 unmodified linefrom .base import MetaItem, BasePipe, Segmentfrom llama_cpp import Llamafrom ..helpers.translator import QwenTranslatorfrom config import LLM_MODEL_PATH, LLM_SYS_PROMPT_EN, LLM_SYS_PROMPT_ZHclass TranslatePipe(BasePipe):translator = None@classmethoddef init(cls):if cls.translator is None:cls.translator = QwenTranslator(LLM_MODEL_PATH, LLM_SYS_PROMPT_EN, LLM_SYS_PROMPT_ZH)def process(self, in_data: MetaItem) -> MetaItem:context = in_data.transcribe_contentresult = self.translator.translate(
117 unmodified lines118119120121122123124117 unmodified linesis_end = Falsefor idx, seg in enumerate(segments):print(">>>>>>>>>>>>>>>>>> seg: ", seg)left_watch_sequences.append(seg)if seg.text and seg.text[-1] in markers:seg_index = int(seg.t1 / 100 * sample_rate)117 unmodified lines118119120121122123117 unmodified linesis_end = Falsefor idx, seg in enumerate(segments):left_watch_sequences.append(seg)if seg.text and seg.text[-1] in markers:seg_index = int(seg.t1 / 100 * sample_rate)
config.py+7-3
transcribe/helpers/translator.py+6-5
transcribe/pipelines/pipe_translate.py+4-4
transcribe/strategy.py-1