Instructions to use webbigdata/gemma-2-2b-jpn-it-translate-gguf 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 webbigdata/gemma-2-2b-jpn-it-translate-gguf 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 webbigdata/gemma-2-2b-jpn-it-translate-gguf:Q4_K_M # Run inference directly in the terminal: llama cli -hf webbigdata/gemma-2-2b-jpn-it-translate-gguf:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf webbigdata/gemma-2-2b-jpn-it-translate-gguf:Q4_K_M # Run inference directly in the terminal: llama cli -hf webbigdata/gemma-2-2b-jpn-it-translate-gguf:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf webbigdata/gemma-2-2b-jpn-it-translate-gguf:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf webbigdata/gemma-2-2b-jpn-it-translate-gguf:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf webbigdata/gemma-2-2b-jpn-it-translate-gguf:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf webbigdata/gemma-2-2b-jpn-it-translate-gguf:Q4_K_M
Use Docker
docker model run hf.co/webbigdata/gemma-2-2b-jpn-it-translate-gguf:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use webbigdata/gemma-2-2b-jpn-it-translate-gguf with Ollama:
ollama run hf.co/webbigdata/gemma-2-2b-jpn-it-translate-gguf:Q4_K_M
- Unsloth Desktop
- Docker Model Runner
How to use webbigdata/gemma-2-2b-jpn-it-translate-gguf with Docker Model Runner:
docker model run hf.co/webbigdata/gemma-2-2b-jpn-it-translate-gguf:Q4_K_M
- Lemonade
How to use webbigdata/gemma-2-2b-jpn-it-translate-gguf with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull webbigdata/gemma-2-2b-jpn-it-translate-gguf:Q4_K_M
Run and chat with the model
lemonade run user.gemma-2-2b-jpn-it-translate-gguf-Q4_K_M
List all available models
lemonade list
- Atomic Chat
Model Card for gemma-2-2b-jpn-it-translate-gguf
gemma-2-2b-jpn-it-translate-ggufใฏใๆฅ่ฑใป่ฑๆฅ็ฟป่จณใฟในใฏใซ็นๅใใSLM๏ผSmall Language Model๏ผใงใใใใฉใกใผใฟใผๆฐใฏ20ๅ๏ผ2B๏ผใงใใใๅ้ใซใใฃใฆใฏๅพๆฅใฎ70ๅ๏ผ7B๏ผใขใใซใซ่ฟซใใฌใใซใฎ็ฟป่จณๅ่ณชใๆไพใใพใใใใกใคใซใตใคใบใ็ด2GB็จๅบฆใงใใใใๆฏ่ผ็ๅฐใใใใใ้ซ้ใชๅฎ่กใๅฏ่ฝใงใใ
gemma-2-2b-jpn-it-translate-gguf is an SLM (Small Language Model) specialized for Japanese-English and English-Japanese translation tasks. Despite having only 2 billion parameters (2B), it provides translation quality approaching that of conventional 7 billion (7B) parameter models in some kind of text. With a relatively small file size of about 2GB, it enables fast execution.
ๆๅไฝใง็ฟป่จณใใไบใๅญฆ็ฟใใฆใใใใใๆน่กใๅซใ้ทๆใไธๅบฆใซๆธกใใจๅ่ณชใไฝไธใใพใใ
้ทๆใ็ฟป่จณใใ้ใฏๆๅไฝใงๅบๅใๅๅฆ็ใใใฆใใใขใใซใซไธใใฆใใ ใใใ
Because the model is trained to translate sentence by sentence, passing a long sentence with line breaks at once will result in a decrease in quality.
When translating a long sentence, please pre-process it by dividing it into sentences before feeding it to the model.
Sample Colab Script
Google ใขใซใฆใณใใใๆใกใฎๆนใฏไปฅไธใฎใชใณใฏๅ
ใงOpen in Colabใใฟใณใๆผใไบใง่ฉฆใไบใใงใใพใ
If you have a Google account, you can try it out by clicking the Open in Colab button at the link below.
Colab sample
sample for windows
ColabใฎCPUใฏ้
ใใฎใงใ่ช่บซใฎใใฝใณใณใงllama.cppใใณใณใใคใซใใฆๅใใๆนใๅฟซ้ฉใงใใ
Colab's CPU is slow, so it is more convenient to compile and run llama.cpp on your own computer.
ใฏใฉใคใขใณใ๏ผใตใผใใผๅฝขๆ
ใงๅไฝใใใใตใณใใซใฏไปฅไธใงใใ
Below is a sample of how it works in client/server mode.
start server.
.\llama.cpp\build\bin\Release\llama-server -m .\gemma-2-2b-jpn-it-translate-Q4_K_L.gguf -c 2048 --override-kv tokenizer.ggml.add_bos_token=bool:false
bosใใผใฏใณ้่คใๅ้ฟใใใใใซใ--override-kv tokenizer.ggml.add_bos_token=bool:false ใชใใทใงใณใๅฟ
ใๆๅฎใใฆใใ ใใใ
Be sure --override-kv tokenizer.ggml.add_bos_token=bool:false options for avoid dup bos token.
pip install -U transformers
pip install requests
import transformers
import requests
import json
from transformers import AutoTokenizer
system_prompt = "You are a highly skilled professional Japanese-English and English-Japanese translator. Translate the given text accurately, taking into account the context and specific instructions provided. Steps may include hints enclosed in square brackets [] with the key and value separated by a colon:. Only when the subject is specified in the Japanese sentence, the subject will be added when translating into English. If no additional instructions or context are provided, use your expertise to consider what the most appropriate context is and provide a natural translation that aligns with that context. When translating, strive to faithfully reflect the meaning and tone of the original text, pay attention to cultural nuances and differences in language usage, and ensure that the translation is grammatically correct and easy to read. After completing the translation, review it once more to check for errors or unnatural expressions. For technical terms and proper nouns, either leave them in the original language or use appropriate translations as necessary. Take a deep breath, calm down, and start translating.\n\n"
instruct = "Translate Japanese to English.\nWhen translating, please use the following hints:\n[writing_style: casual]"
initial_messages = [
{"role": "user", "content": system_prompt + instruct},
{"role": "assistant", "content": "OK"}
]
message_list = [
"and I was a little bit nervous, too, speaking to a Japanese audience really for the first time, certainly since I left the White House. ",
"And I had a very good interpreter, and if you have ever made a speech in Japan in English, it takes a lot longer to say it in Japanese. ",
"I decided I would break the ice by telling the shortest joke that I knew.",
"It was not the best joke I knew, but it was the shortest joke I knew, left over from my governor's campaign years before.",
"So I told my joke, the interpreter told the joke, and the audience just collapsed in laughter. ",
"I never got a better response from any audience in my life. ",
"So I could not wait to get through the speech and talk to the interpreter and ask him,"
"\"How did you tell my joke?\"",
"He was very evasive. He would not tell me how he told it.",
"I insisted, and he finally ducked his head and said,",
"\"I told the audience, 'President Carter told a funny story. Everybody, laugh.'\""
]
tokenizer = AutoTokenizer.from_pretrained("webbigdata/gemma-2-2b-jpn-it-translate")
if __name__ == "__main__":
messages = initial_messages.copy()
for i in range(len(message_list)):
messages.append({"role": "user", "content": message_list[i]})
print("user: " + message_list[i])
# Transformersใฎใใผใฏใใคใถใผใไฝฟใใใใชใๅ ดๅใฏใColabใฎใตใณใใซใๆใงใใญใณใใใใณใใฌใผใใๆธใใฆใใฎใงใใกใใๅ่ใใฆใใ ใใ
# If you donโt want to use the Transformers tokenizer, you can use the Colab example to manually write the prompt template.
prompt = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=False
)
payload = {
"prompt": prompt,
"n_predict": 1200
}
# Define the URL and headers for the POST request
url = "http://localhost:8080/completion"
headers = {
"Content-Type": "application/json"
}
# Send the POST request and capture the response
response = requests.post(url, headers=headers, data=json.dumps(payload))
# print(response)
# print( response.json() )
# Check if the request was successful
if response.status_code != 200:
print(f"Error: {response.text}")
# Parse the response JSON
response_data = response.json()
# Extract the 'content' field from the response
response_content = response_data.get('content', '').strip()
print("assistant: " + response_content)
messages.append({"role": "assistant", "content": response_content})
# Max 6 message, you need more memory for more massages.
if len(messages) > 8: # 2 (initial) + 6 (new) = 8
messages = initial_messages + messages[-6:]
result
user: and I was a little bit nervous, too, speaking to a Japanese audience really for the first time, certainly since I left the White House.
assistant: ใใใฆใ็งใใกใใฃใจ็ทๅผตใใฆใใพใใใ็ฝๅฎฎใ้ขใใฆใใใๆฅๆฌไบบใฎๅใงๅใใฆใๆฌๅฝใฎๆๅณใง่ฉฑใใฆใใใจใใใฎใฏ ใใใชใๅใงใใใ
user: And I had a very good interpreter, and if you have ever made a speech in Japan in English, it takes a lot longer to say it in Japanese.
assistant: ใใใฆใ็งใฏใจใฆใๅชใใ้่จณใใใฆใใใใใชใใ่ฑ่ชใงๆฅๆฌใง่ฌๆผใใใใใใใใจใใใใฎใชใใๆฅๆฌ่ชใง่ฉฑใใฎ ใซใฏใใใซ้ทใใชใใพใใ
user: I decided I would break the ice by telling the shortest joke that I knew.
assistant: ใใใงใๆใ็ญใใธใงใผใฏใ่ฉฑใใฆใๆๅใฎใใกใฏๆฐใ็ทฉใพใใใใจๆฑบใใใฎใงใใ
user: It was not the best joke I knew, but it was the shortest joke I knew, left over from my governor's campaign years before.
assistant: ไธ็ชใฎใธใงใผใฏใงใฏใชใใงใใใ็งใฎ็ฅใฃใฆใใ็ญใใธใงใผใฏใใใใพใง governors ใฎ้ธๆใงใฎใญใฃใณใใผใณไธญใซใใใใฎใงใใ
user: So I told my joke, the interpreter told the joke, and the audience just collapsed in laughter.
assistant: ใใใงใ็งใ็งใฎใธใงใผใฏใ่จใฃใใใ้่จณใ็งใฎใธใงใผใฏใใใใใฆใชใผใใฃใจใณในใฏใใ ใใ ็ฌใ่ปขใใพใใใ
user: I never got a better response from any audience in my life.
assistant: ็งใฏใใฎใธใงใผใฏใฏใไปใพใงใซใใใไปฅไธใใๅๅฟใใใใฃใใใจใใใใพใใใงใใใ
user: So I could not wait to get through the speech and talk to the interpreter and ask him,"How did you tell my joke?"
assistant: ใใใงใ็งใฏใใใฎๆผ่ชฌใ็ตใใใใฆใ้่จณใจ่ฉฑใใฎใๅพ
ใกใใใชใใงใใใฎ้่จณใซๅฐใญใใใจๆใฃใฆใใพใใใใใฉใฎ ใใใซ็งใฎใธใงใผใฏใไผใใใฎ๏ผใ
user: He was very evasive. He would not tell me how he told it.
assistant: ๅฝผใฏใจใฆใ้ฟใใฆใใพใใใใฉใใใใฎใใจๆใใฆใใใพใใใ
user: I insisted, and he finally ducked his head and said,
assistant: ๆญใใพใใจใๅฝผใฏใคใใซ้ฆใใใใใฆใใ
user: "I told the audience, 'President Carter told a funny story. Everybody, laugh.'"
assistant: ใๅธไผ่
ใใใใซใผใฟใผๅคง็ตฑ้ ใ้ข็ฝใ่ฉฑใใใใ็ใใใ็ฌใฃใฆใใ
ใใณใใใผใฏ็ตๆ Benchmark results
Q4KL
| filename | direction | spBLEU | chrF2++ | comet | xlcomet |
|---|---|---|---|---|---|
| flores200v1 | enja | 21.94 | 30.8 | 0.8714 | 0.7496 |
| flores200v1 | jaen | 21.28 | 52.2 | 0.8577 | 0.8965 |
| wmt23 | jaen | 14.46 | 41.5 | 0.7859 | 0.8353 |
| wmt20 | enja | 14.15 | 25.2 | 0.8519 | 0.6701 |
| wmt23 | enja | 13.96 | 25.4 | 0.8339 | 0.7500 |
| Business | jaen | 19.14 | 42.7 | 0.8084 | 0.8309 |
| wmt20 | jaen | 13.23 | 41.8 | 0.7807 | 0.7187 |
| Business | enja | 17.53 | 33.7 | 0.8809 | 0.8604 |
่ฌ่พ Acknowledgements
- Developed by: [dahara1@webbigdata]
- Language(s) (NLP): [English, Japanese]
- base model [optional]: gemma-2-2b-jpn-it
- original model [optional]: gemma-2-2b-jpn-it-translate
BibTeX:
@misc{dahara2024imatrix,
author = {dahara1@webbigdata},
title = {gemma-2-2b-jpn-it-translate: A translation task-specific gguf model based on gemma-2-2b-jpn-it},
year = {2024},
howpublished = {\url{https://huggingface.co/webbigdata/gemma-2-2b-jpn-it-translate-gguf/}},
note = {Accessed: 2024-10-10},
abstract = {This model was developed to verify how much Japanese-English and English-Japanese translation performance can be improved with the 2B gguf model.},
}
- Downloads last month
- 541