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"
daihui.zhang commited on
Commit ·
485d8e3
1
Parent(s): ded2334
change to pipelines
Browse filesFiles changed (7)
- transcribe/pipelines/__init__.pyAdded+4
- transcribe/pipelines/base.pyAdded+50
- transcribe/pipelines/pipe_translate.pyAdded+22
- transcribe/pipelines/pipe_vad.pyAdded+3
- transcribe/pipelines/pipe_whisper.pyAdded+28
- transcribe/translatepipes.pyAdded+56
- transcribe/whisper.pyAdded+47
1234
from .pipe_translate import TranslatePipefrom .pipe_whisper import WhisperPipefrom .base import MetaItem1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
from dataclasses import dataclass, fieldfrom multiprocessing import Process
@dataclassclass Segment: t0: int t1: int text: str
@dataclassclass MetaItem: segments: list[Segment] = field(default_factory=list) audio: bytes = b'' transcribe_content: str = '' translate_content: str = '' source_language: str = 'zh' destination_language: str = 'en'
class BasePipe(Process): def __init__(self, in_queue, out_queue) -> None: super().__init__() # Initialize the Process class self._in_queue = in_queue self._out_queue = out_queue
@property def output_queue(self): return self._out_queue @property def input_queue(self): return self._in_queue def process(self, in_data: MetaItem) -> MetaItem: raise NotImplementedError("Subclasses should implement this method.")
@classmethod def init(cls): raise NotImplementedError
def run(self): self.init() while True: item = self._in_queue.get() if item is None: # Check for termination signal break out_item = self.process(item) self._out_queue.put(out_item)12345678910111213141516171819202122
from .base import MetaItem, BasePipe, Segmentfrom llama_cpp import Llamafrom ..translator import QwenTranslatorfrom config import LLM_MODEL_PATH, LLM_SYS_PROMPT
class TranslatePipe(BasePipe): translator = None @classmethod def 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_content result = self.translator.translate( context, src_lang=in_data.source_language, dst_lang=in_data.destination_language) in_data.translate_content = result return in_data
123
from .base import MetaItem, BasePipe12345678910111213141516171819202122232425262728
from .base import MetaItem, BasePipe, Segmentfrom ..whisper import WhisperCPP
class WhisperPipe(BasePipe): whisper = None
def __init__(self, in_queue, out_queue) -> None: super().__init__(in_queue, out_queue)
@classmethod def init(cls): if cls.whisper is None: cls.whisper = WhisperCPP()
def process(self, in_data: MetaItem) -> MetaItem: audio_data = in_data.audio source_language = in_data.source_language segments = self.whisper.transcribe(audio_data, source_language) texts = "".join([s.text for s in segments]) in_data.segments = [Segment(t0=s.t0, t1=s.t1, text=s.text) for s in segments] in_data.transcribe_content = texts in_data.audio = b"" return in_data1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556from transcribe.pipelines import WhisperPipe, TranslatePipe, MetaItemimport multiprocessing as mpimport config
class TranslatePipes: def __init__(self) -> None: self.whisper_input_q = mp.Queue() self.translate_input_q = mp.Queue() self.result_queue = mp.Queue() # whisper 转录 self._whisper_pipe = WhisperPipe( in_queue=self.whisper_input_q, out_queue=self.translate_input_q ) # llm 翻译 self._translate_pipe = TranslatePipe( in_queue=self.translate_input_q, out_queue=self.result_queue, ) self._whisper_pipe.daemon = True self._whisper_pipe.start()
self._translate_pipe.daemon = True self._translate_pipe.start()
def translate(self, text, src_lang, dst_lang) -> MetaItem: item = MetaItem( transcribe_content=text, source_language=src_lang, destination_language=dst_lang) self._translate_pipe.input_queue.put(item) return self._translate_pipe.output_queue.get()
def transcrible(self, audio_buffer:bytes, src_lang: str) -> MetaItem: item = MetaItem(audio=audio_buffer, source_language=src_lang) self._whisper_pipe.input_queue.put(item) return self._whisper_pipe.output_queue.get()
if __name__ == "__main__": import soundfile tp = TranslatePipes() # result = tp.translate("你好,今天天气怎么样?", src_lang="zh", dst_lang="en") mel, _, = soundfile.read("assets/jfk.flac") result = tp.transcrible(mel, 'en') print(result)
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647from pywhispercpp.model import Modelimport soundfileimport configimport numpy as np
class WhisperCPP:
def __init__(self, warmup=True) -> None: models_dir = config.MODEL_DIR.as_posix() self.model = Model( model=config.WHISPER_MODEL, models_dir=models_dir, print_realtime=False, print_progress=False, print_timestamps=False, ) if warmup: self.warmup()
def warmup(cls, warmup_steps=1): mel, _, = soundfile.read("assets/jfk.flac") for _ in range(warmup_steps): cls.model.transcribe(mel, print_progress=False)
@staticmethod def config_language(language): if language == "zh": return config.MAX_LENTH_ZH, config.WHISPER_PROMPT_ZH elif language == "en": return config.MAX_LENGTH_EN, config.WHISPER_PROMPT_EN raise ValueError(f"Unsupported language : {language}")
def transcribe(self, audio_buffer:bytes, language): max_len, prompt = self.config_language(language) audio_buffer = np.frombuffer(audio_buffer, dtype=np.float32) print("audio buffer got:", len(audio_buffer)) output = self.model.transcribe( audio_buffer, initial_prompt=prompt, language=language, token_timestamps=True, max_len=max_len ) return output transcribe/pipelines/__init__.pyAdded+4
transcribe/pipelines/base.pyAdded+50
transcribe/pipelines/pipe_translate.pyAdded+22
transcribe/pipelines/pipe_vad.pyAdded+3
transcribe/pipelines/pipe_whisper.pyAdded+28
transcribe/translatepipes.pyAdded+56
transcribe/whisper.pyAdded+47