library_name: peft
base_model: unsloth/gemma-2-9b-it-bnb-4bit
language:
- ja
- en
tags:
- translation
- qlora
- gemma2
- text-generation-inference
- nlp
license: apache-2.0
News
2024.07.20
C3TR-Adapterã®Version3ãå
¬éããŸããã
Version 3 of C3TR-Adapter has been released.
version3ã§ã¯4ã€ã®ãã³ãããŒã¯ã®ãã¡ã1ã€ã§gpt4 turboãäžåããšãã倧å¹
ãªæ§èœåºäžããéæãããŠããŸãã
Version 3 achieved a significant performance boost, beating GPT4 Turbo in one of the four benchmarks.
2024.05.17
C3TR-Adapterã®Version2ãå
¬éããŸããã
Version 2 of C3TR-Adapter has been released.
Version2ã§ã¯äž»ã«ã«ãžã¥ã¢ã«ãªäŒè©±ã«é¢ãã翻蚳èœåã倧å¹
ã«åäžããŠããŸãã
Version 2 has greatly improved the ability to translate casual conversations.
ãã®åé¢ããã©ãŒãã«ãªæç« ã®ç¿»èš³èœåãå°ãèœã¡ãŠããŸã£ãŠããŸãããã©ãŒãã«ãªæç« ã察象ã«ããå ŽåãVersion1ãåŒãç¶ãã䜿ããã ãã
On the other hand, translation capabilities for formal texts have declined slightly. If you are targeting formal texts, please continue to use Version1.
ã¢ãã«ã«ãŒã(Model Card for Model ID)
C3TR-Adapterã¯Googleãçºè¡šããLLMã§ããgemma-2-9bã®æ¥è±ã»è±æ¥ç¿»èš³æ§èœãåäžãããQLoRA Adapterã§ãã
C3TR-Adapter is a QLoRA Adapter that improves the Japanese-English and English-Japanese translation performance of gemma-2-9b released by Google.
ã¢ãã«è©³çŽ°(Model Details)
C3TR-Adapterã¯ç¿»èš³ãã³ãããŒã¯ã§å€èšèªç¿»èš³ã¢ãã«ã§ããGoogleã®Madlad400ãmetaã®Seamless m4t v2 largeãALMA-Ja-V2 (ç§éã®ä»¥åã®llama 2ããŒã¹ã®ã¢ãã«)ããã倧å¹
ã«åªããæ¥è±ã»æ¥è±ç¿»èš³æ§èœãæã£ãŠããŸãã
Benchmarks show significantly better English-Japanese and Japanese-English translation performance than Google's Madlad400, META's Seamless m4t v2 large, and ALMA-Ja-V2 (our previous llama2 model).
翻蚳ã¿ã¹ã¯ã«é¢ããŠã¯ããã倧ããªã¢ãã«ã«è² ããªãæ§èœãçºæ®ããŸã
å
ã®ç»åã¯ã¬ãžãã Sebastian Ruder(@seb_ruder)
For translation tasks, it performs as well as larger models.
Original image credit: Sebastian Ruder (@seb_ruder)
翻蚳ãã³ãããŒã¯ã®å®è¡æ¹æ³ããã®ä»ã®ãã³ãããŒã¯çµæã«ã€ããŠã¯JTransBenchãåèã«ããŠãã ããã
For instructions on how to run the translation benchmark and other benchmark results, please refer to JTransBench.
Googleã®ãŠã§ããµãŒãã¹Colabã䜿ããšç¡æã§C3TR-Adapterãè©Šãäºãåºæ¥ãŸãããªã³ã¯å
ã§Open In Colabãã¿ã³ãæŒããŠèµ·åããŠãã ããã
You can try C3TR-Adapter for free using Google's web service Colab. Please press the Open In Colab button on the link to activate it.
- åäœç¢ºèªçšã®ç°¡åãªãµã³ãã«(A simple sample to check the operation)
- ããã¹ããã¡ã€ã«ãäžæ¬ã§æ¥è±ã»è±æ¥ç¿»èš³ãããµã³ãã«(Sample of batch translation of text files)
- GPUããªãç°å¢ã§ãåããäºãã§ããggufç(A gguf version that can be run in environments without a GPU)
ã¢ãã«ã®åããæ¹(How to use Model)
èªåã®ããœã³ã³ã§åããå Žåã¯ãå°ãªããšãçŽ8.3GB以äžã®GPU RAMãå¿
èŠã§ããGPUã¡ã¢ãªã足ããªãå Žåã¯äžèšã®ggufçãè©Šããããã©ã¡ãŒã¿ãŒã調æŽããŠãã ãã(max_lengthãmax_new_tokens, num_beamsãæžãã)
If you want to run it on your own local computer, you will need at least approximately 8.3 GB or more of GPU RAM.If you do not have enough GPU memory, try the gguf version above or decrease parameters(max_lengthãmax_new_tokens, num_beams).
å¿ èŠãªã©ã€ãã©ãªã®ã€ã³ã¹ããŒã«(Installation of required libraries)
# ãããpytorchããŸã ã€ã³ã¹ããŒã«ãããŠããªãã£ããå
¬åŒããã¥ã¢ã«ãåèã«ã€ã³ã¹ããŒã«ããŠãã ãã
# If pytorch is not already installed, please refer to the official manual to install it.
# https://pytorch.org/get-started/locally/#start-locally
# example for linux user with CUDA 12.1.
# pip3 install torch torchvision torchaudio
# example for windows user with CUDA 12.1.
# pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
# Gemma 2ã¯ææ°ã®ã©ã€ãã©ãªã§ãªããŠã¯åããªãã®ã§ã以äžã®Versionã«æŽæ°ããŠãã ãã
# Gemma 2 will not work without the latest library, so please update to the following version
pip install transformers==4.42.3
pip install peft==0.11.1
pip install bitsandbytes==0.43.1
ãµã³ãã«ã¹ã¯ãªãã(sample script)
import torch
import os
import json
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
model_id = "unsloth/gemma-2-9b-it-bnb-4bit"
peft_model_id = "webbigdata/C3TR-Adapter"
if torch.cuda.is_available() and torch.cuda.get_device_capability(0)[0] >= 8:
dtype = torch.bfloat16
else:
dtype = torch.float16
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=dtype, device_map="auto")
model = PeftModel.from_pretrained(model = model, model_id = peft_model_id)
tokenizer = AutoTokenizer.from_pretrained(model_id)
tokenizer.pad_token = tokenizer.unk_token
def trans(my_str):
input_ids = tokenizer(my_str, return_tensors="pt",
padding=True, max_length=1800, truncation=True).input_ids.cuda()
# Translation
generated_ids = model.generate(input_ids=input_ids,
max_new_tokens=900, use_cache=True,
do_sample=True, num_beams=3, temperature=0.5, top_p=0.3,
repetition_penalty=1.0
)
full_outputs = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
return full_outputs[0].split("### Response:\n")[-1].strip()
ret = trans("""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.
<start_of_turn>### Instruction:
Translate Japanese to English.
### Input:
ããïŒãŸãå€é£ãé£ã¹ãŠãã®ïŒ
ããã«ããã¯å€ªããŸãã
<end_of_turn>
<start_of_turn>### Response:
""")
print(ret)
ããã³ãããã©ãŒããã prompt format
ããã³ãããã©ãŒãããã¯ç¬èªã§ãã The prompt format is original.
Version1ãšVersion2(ã·ã¹ãã ããã³ããè¿œå )ãšVersion3(<start_of_turn>
ãš<end_of_turn>
è¿œå )ã§ã¯ããã³ãããã©ãŒããããå€ãã£ãŠããŸãã
The prompt format has changed between Version 1, Version2(add system prompts) and Version 3(add <start_of_turn>
and<end_of_turn>
).
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.
<start_of_turn>### Instruction:
Translate Japanese to English.
### Input:
**Some Japanese text**
<end_of_turn>
<start_of_turn>### Response:
ãŸã㯠or
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.
<start_of_turn>### Instruction:
Translate English to Japanese.
### Input:
**Some English text**
<end_of_turn>
<start_of_turn>### Response:
ããã³ãããã³ãã¬ãŒãå
ã«äœåãªç©ºçœãæ¹è¡ã<start_of_turn>
ãš<end_of_turn>
ã®æŒãã¯ã¢ãã«ã®èª€åäœ(åºåãéåãããç¹°ãè¿ããäœåãªæç« ãä»å ãããç)ã«ç¹ããã®ã§ãã³ãã¬ãŒãã«ãã¹ããªãããã«ããŠãã ãã
Extra spaces, line breaks, and omission of <start_of_turn>
or <end_of_turn>
in the prompt template will cause the model to malfunction (output will be truncated or repeated, extra sentences will be added, etc.), so please make sure there are no errors in the template.
Version2ããã¯å®éšçãªè©Šã¿ãšããŠã翻蚳æã«ãã³ããäžããäºãåºæ¥ãããã«ãªã£ãŠããŸãã
Starting with Version 2, as an experimental attempt, it is now possible to provide hints during translation.
(1)æäœ(writing style)
[writing_style: STYLE_NAME]
çŸåšã¯è©Šéšçã«11ã®writeing styleããã¹ãå®è£
ããŠããŸãã
We are currently testing 11 writing styles.
casual, formal, technical, journalistic, web-fiction, business, nsfw, educational-casual, academic-presentation, slang, sns-casual
ä»äºå Žãªã©ã§ã¯businessã䜿ããŸã
In the workplace, we use business.
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.
<start_of_turn>### Instruction:
Translate Japanese to English.
When translating, please use the following hints:
[writing_style: business]
### Input:
ãç²ãæ§ã§ããæ¬æ¥ã®è³æãéããŸãã
<end_of_turn>
<start_of_turn>### Response:
Thank you for your hard work today. I am sending today's materials.
以éã®äŸã§ã¯system promptãçç¥ããŠããŸãããå®éã«åããéã«ã¯system promptãè¿œå ããŠãã ããã
The following examples omit the system prompt, but be sure to add it when running the commands.
ã³ãããªã©ã§ã¯slangãcasualã䜿ããŸã
Use slang or casual language when meme.
<start_of_turn>### Instruction:
Translate Japanese to English.
When translating, please use the following hints:
[writing_style: slang]
[çé®å®é£: Beef salmon set meal]
### Input:
ãããªäºãã >>1 ããã¡ãããšèããŠããããã¹ã¬ãšãããŸé¢ä¿ãªããã©ãã
ãã®ããã ãè¿æã®åé家è¡ã£ããã§ããåé家ã
ãããããªãã人ããã¡ããã¡ããã£ã±ãã§åº§ããªããã§ãã
ã§ãããèŠãããªããåãå¹äžãã£ãŠãŠã150ååŒãããšãæžããŠãããã§ãã
ããããã¢ãããšã銬鹿ããšã
ãåããªã150ååŒãåŠãã§æ®æ®µæ¥ãŠãªãåé家ã«æ¥ãŠãããããŒãããã±ãã
150åã ãã150åã
ãªãã芪åé£ããšããããããäžå®¶4人ã§åé家ããããã§ãŠãŒãªã
ããŒãããç¹çé ŒããããããŒããšãèšã£ãŠãã®ãããèŠãŠãããªãã
ãåããªã150åãããããã®åžç©ºãããšã
åé家ã£ãŠã®ã¯ãªããã£ãšæ®ºäŒãšããŠãã¹ããªãã ãã
Uã®åããŒãã«ã®åããã«åº§ã£ã奎ãšãã€å§å©ãå§ãŸã£ãŠããããããªãã
åºããåºããããããããªé°å²æ°ããããããããŒãã女åäŸã¯ããã£ããã§ãã
ã§ããã£ãšåº§ããããšæã£ãããé£ã®å¥Žãã倧çã€ãã ãã§ããšãèšã£ãŠããã§ãã
ããã§ãŸãã¶ã¡åãã§ããã
ãã®ãªãã€ãã ããªããŠãããã³æµè¡ãããŒãã ãããã±ãã
åŸæããªé¡ããŠäœããã€ãã ãã§ãã ã
ãåã¯æ¬åœã«ã€ãã ããé£ãããã®ããšåããããåãè©°ããããå°1æéåãè©°ãããã
ãåãã€ãã ãã£ãŠèšãããã ãã¡ãããããšã
åé家éã®ä¿ºããèšãããŠãããã°ä»ãåé家éã®éã§ã®ææ°æµè¡ã¯ãã£ã±ãã
ããã ããããã ãã
倧çãããã ãã®ã§ã¯ããããéã®é Œã¿æ¹ã
ããã ãã£ãŠã®ã¯ãããå€ãã«å
¥ã£ãŠãããã代ããèãå°ãªããããã
ã§ãããã«å€§çãã®ã§ã¯(çå)ãããæ匷ã
ããããããé Œããšæ¬¡ããåºå¡ã«ããŒã¯ããããšããå±éºã䌎ããè«žåã®å£ã
çŽ äººã«ã¯ãèŠãåºæ¥ãªãã
ãŸããåã>>1ã¯ãçé®å®é£ã§ãé£ã£ãŠãªããã£ãŠãã£ã
<end_of_turn>
<start_of_turn>### Response:
Instead of that >>1, hey, just listen for a bit. It's not really related to the thread.
The other day, I went to a Yoshinoya near my place. Yoshinoya.
Then, there were so many people that I couldn't find a seat.
And when I took a closer look, there was a banner hanging down, saying "150 yen off," or something like that.
I mean, what a bunch of idiots.
You guys, don't come to Yoshinoya just for a 150 yen discount, you idiots.
It's only 150 yen, 150 yen.
There were even some families with kids. A family of four at Yoshinoya. Congratulations.
"Let's order the extra-large portion," they say. I can't take it anymore.
You guys, if you're going to spend 150 yen, clear your seat.
Yoshinoya should be a more brutal place.
You should be ready to fight the guy sitting across from you at the U-shaped table at any moment.
A place where you're either stabbing or being stabbed. Women and children, get out of the way.
And just when I finally got a seat, the guy next to me said, "I'll have the extra-large portion with extra sauce."
And I lost it again.
You know, extra sauce isn't popular these days, you idiot.
What are you so proud of, ordering extra sauce?
I want to ask you, do you really want to eat extra sauce? I want to interrogate you for an hour.
You just want to say "extra sauce," don't you?
As a Yoshinoya regular, I can tell you that the latest trend among Yoshinoya regulars is still,
extra onions. That's the way to go.
Extra-large portion with extra onions. That's the regular's order.
Extra onions means more onions and less meat. That's it.
And with that, an extra-large egg. That's the best.
However, ordering this comes with the risk of being marked by the staff. It's a double-edged sword.
I don't recommend it for amateurs.
Well, you, >>1, why don't you just order the beef salmon set meal?
(2)åºæåè©ã®èªã¿æ¹ How to read proper nouns
[è±èªå称: æ¥æ¬èªèš³] ãŸãã¯ãã®éã
[English name: Japanese translation name] or vice versa
<start_of_turn>### Instruction:
Translate Japanese to English.
When translating, please use the following hints:
[writing_style: formal]
[矜ççµåŒŠ: Yuzuru Hanyu]
[矜çåæ²»: Yoshiharu Habu]
### Input:
ãã£ã®ã¥ã¢ã¹ã±ãŒãã®çŸœççµåŒŠãããå°æ£æ£å£«ã®çŸœçåæ²»ãããšå¯Ÿè«ãã
<end_of_turn>
<start_of_turn>### Response:
Figure skater Yuzuru Hanyu had a conversation with shogi player Yoshiharu Habu.
(3)ãã£ã©ã¯ã¿ãŒã¹ã¿ã€ã« character_style
[XXXX_character_style: YYYY]
ãã£ã©ã¯ã¿ãŒã¹ã¿ã€ã«ã§æ§å¥ãåæ§ãæå®ããäºãã§ããŸã
You can specify gender and personality in the character style.
ç·æ§æå® Male designated
<start_of_turn>### Instruction:
Translate Japanese to English.
When translating, please use the following hints:
[writing_style: formal]
[é山暹_character_style: male]
[é山暹: AOYAMA Itsuki]
### Input:
é山暹ã¯é±æ«ã«åéãšãã£ã³ãã«è¡ã£ãŠãèªç¶ã楜ããã ããããŠæèšãçŽå€±ããã
<end_of_turn>
<start_of_turn>### Response:
Aoyama Itsuki went camping with his friends on the weekend and enjoyed nature. However, he lost his watch.
女æ§æå® Female designated
<start_of_turn>### Instruction:
Translate Japanese to English.
When translating, please use the following hints:
[writing_style: formal]
[é山暹_character_style: female]
[é山暹: Itsuki Aoyama]
### Input:
é山暹ã¯é±æ«ã«åéãšãã£ã³ãã«è¡ã£ãŠãèªç¶ã楜ããã ããããŠæèšãçŽå€±ããã
<end_of_turn>
<start_of_turn>### Response:
Itsuki Aoyama went camping with friends on the weekend and enjoyed nature. However, she lost her watch.
ãã³ãã€ããªãŒæå® nonbinary designated
<start_of_turn>### Instruction:
Translate Japanese to English.
When translating, please use the following hints:
[writing_style: formal]
[é山暹_character_style: nonbinary]
[é山暹: Tatsuki Aoyama]
### Input:
é山暹ã¯é±æ«ã«åéãšãã£ã³ãã«è¡ã£ãŠãèªç¶ã楜ããã ããããŠæèšãçŽå€±ããã
<end_of_turn>
<start_of_turn>### Response:
Tatsuki Aoyama went camping with their friends on the weekend and enjoyed nature. They lost their watch.
æ®å¿µãªããçŸæç¹ã§ã¯æ§å¥ã®æå®ã¯æ¬æã®å
容ãåªå
ããããããäŸãã°ä»¥äžã®æç« ã§ã¯æ§å¥æå®ãæå¹ã«ãªããŸããã
以äžã®äŸã§ã¯æ¬æå
ã®ã俺ã¯ç·ã ã!ããæ¶ãã°æ§å¥æå®ãæå¹ã«ãªããŸãã
ãŸããbfloat16ãæ±ããªãColabã®ç¡æçãªã©ã§ã¯ãã®æå®ãç¡èŠãããŠããŸãããã§ãã
Unfortunately, at present, the content of the text takes priority when designating gender, so for example, the gender designation will not be effective in the following sentence.
In the example below, if you delete "俺ã¯ç·ã ã!(I'm a guy!)" from the text, the gender specification will be effective.
Also, this specification seems to be ignored in the free version of Colab, which cannot handle bfloat16.
<start_of_turn>### Instruction:
Translate Japanese to English.
When translating, please use the following hints:
[writing_style: web-fiction]
[ã«ããŒãŠ: kamille]
[kamille_character_style: female, rough, teenager]
[ãžã¥ãªã: Jerid]
[ãã£ã¿ãŒã³ãº: Titans]
[ãšã: Emma]
[ãšã¥ãŒãŽ: A.E.U.G.]
### Input:
ãžã§ãªãã«ããŒãŠïŒå¥³ã®ååãªã®ã«ã»ã»ã»äœã ãç·ãã
ã«ããŒãŠïœ¢ãªãããª!!
ãžã§ãªããã!
ãšããããªãã!
ãžã§ãªããªã¬éããã£ã¿ãŒã³ãºãšç¥ã£ãŠã¡ãã£ãããåºããŠããã®ã?
ã«ããŒãŠïœ¢ã«ããŒãŠãç·ã®ååã§äœã§æªããã !!!俺ã¯ç·ã ã!
ããããŠå°çé£éŠã®ãšãªãŒãéšéã»ãã£ã¿ãŒã³ãºã殎ã£ã眪ã§ææãããåŸãæ¯ã倱ããåå°çé£éŠçµç¹ããšã¥ãŒãŽãã«åå ããŸããã
<end_of_turn>
<start_of_turn>### Response:
Jerid: "Kamille? That's a woman's name... What, are you a man?"
Kamille: "Don't underestimate me!!"
Jerid: "Whoa!"
Emma: "Stop it!"
Jerid: "Did you provoke us because you know we're from the Titans?"
Kamille: "What's wrong with my name being Kamille? I'm a man!"
After being arrested for assaulting members of the Earth Federation's elite unit, the Titans, Kamille lost his mother and joined the anti-Earth Federation organization, A.E.U.G.
character_styleãšwriting_styleãçµã¿åããã
Combining character_style and writing_style
以äžã®äŸã§ã¯æ®µã
ãšäžå¯§ãªèšãåãã«å€åããŠããŸã
In the following example, the phrase gradually changes to a more polite one.
<start_of_turn>### Instruction:
Translate Japanese to English.
When translating, please use the following hints:
[writing_style: slang]
[speaker_character_style: vulgar]
### Input:
ä»æ¥ã®äŒè°ã¯éåžžã«éèŠã§ãã®ã§ãæééãã«æ¥ãŠãã ããã
<end_of_turn>
<start_of_turn>### Response:
Today's meeting is super important, so show up on time.
<start_of_turn>### Instruction:
Translate Japanese to English.
When translating, please use the following hints:
[writing_style: casual]
[speaker_character_style: rough]
### Input:
ä»æ¥ã®äŒè°ã¯éåžžã«éèŠã§ãã®ã§ãæééãã«æ¥ãŠãã ããã
<end_of_turn>
<start_of_turn>### Response:
Today's meeting is very important, so please come on time.
<start_of_turn>### Instruction:
Translate Japanese to English.
When translating, please use the following hints:
[writing_style: formal]
[speaker_character_style: noble]
### Input:
ä»æ¥ã®äŒè°ã¯éåžžã«éèŠã§ãã®ã§ãæééãã«æ¥ãŠãã ããã
<end_of_turn>
<start_of_turn>### Response:
Today's meeting is of great importance, so please come on time.
æ¥æ¬èªã§ãåæ§ã«äžå¯§ã«ãªã£ãŠãã£ãŠããŸã
The Japanese language is also becoming more polite.
<start_of_turn>### Instruction:
Translate English to Japanese.
When translating, please use the following hints:
[writing_style: slang]
[speaker_character_style: vulgar]
### Input:
Since today's meeting is very important, please arrive on time.
<end_of_turn>
<start_of_turn>### Response:
ä»æ¥ã®äŒè°ã¯éåžžã«éèŠãªã®ã§ãæéå³å®ã§æ¥ãŠãã ããã
<start_of_turn>### Instruction:
Translate English to Japanese.
When translating, please use the following hints:
[writing_style: casual]
[speaker_character_style: rough]
### Input:
Since today's meeting is very important, please arrive on time.
<end_of_turn>
<start_of_turn>### Response:
ä»æ¥ã®äŒè°ã¯è¶
éèŠã ãããæéå³å®ã§æ¥ãã
<start_of_turn>### Instruction:
Translate English to Japanese.
When translating, please use the following hints:
[writing_style: formal]
[speaker_character_style: noble]
### Input:
Since today's meeting is very important, please arrive on time.
<end_of_turn>
<start_of_turn>### Response:
ä»æ¥ã®äŒè°ã¯éåžžã«éèŠãªã®ã§ãæéå³å®ã§ååããŠãã ããã
(4)äžäººç§°ãšèªå°Ÿ(First person and ending)
ãã£ã©ã¯ã¿ãŒã®äžäººç§°ãšèªå°Ÿãæå®ããäºãã§ããŸãã
ãã®æ©èœã¯ãŸã éåžžã«å®éšçãªæ©èœã§ãããçŸæç¹ã§ã¯äžå®å
šã§ãã
You can specify the first person and ending for your character.
This feature is still highly experimental and incomplete at this time.
æ ç»ãherãããäžå Žé¢(A scene from the movie "her")
<start_of_turn>### Instruction:
Translate English to Japanese.
When translating, please use the following hints:
[writing_style: web-fiction, nsfw]
[THEODORE: ã»ãªãã¢]
[SEXYKITTEN: ã»ã¯ã·ãŒãªåç«]
[SEXYKITTEN_character_style: female]
[THEODORE_character_style: male]
[SEXYKITTEN_first_person_and_ending: ç§, ã ã]
[THEODORE_first_person_and_ending: å, ã ã]
### Input:
SEXYKITTEN:Choke me with that dead cat!
THEODORE:(breathing hard about to climax) What?
SEXYKITTEN:(fully into it) The dead cat next to the bed. Choke me with it!
Beat. He's taken out of it.
THEODORE:(uncomfortable, trying to play along) Um, okay.
SEXYKITTEN:Tell me.
THEODORE:I'm choking you with the cat.
SEXYKITTEN:TELL ME! Keep telling me!
THEODORE:I've got it's tail and I'm choking you with the cat's tail.
SEXYKITTEN:YEAH, YOU ARE! FUCK! TELL ME!
THEODORE:I'm choking you and it's tail is around your neck. It's so tight around your neck.
SEXYKITTEN:YES! YES!
Theodore doesn't know what to say. He doesn't want to offend her.
THEODORE:I'm pulling it. I'm pulling it. The cat's dead. It's a dead cat around your neck and I'm pulling it.
SEXYKITTEN:AHHHHHHHHHHHH. OH MY GOD!
Her breathing is slowing down.
SEXYKITTEN:Oh god, I came so hard.
THEODORE:Yeah. Me too.
SEXYKITTEN:Okay, good night.
Theodore takes his earpiece out and stares at the ceiling.
### Response:
ã»ã¯ã·ãŒãªåç«:ãã®æ»ãã ç«ã§ç§ãçµãã€ããïŒ
ã»ãªãã¢:(æ¯ãèãã快楜ã«è¿ã¥ã) äœïŒ
ã»ã¯ã·ãŒãªåç«:(倢äžã«ãªã£ãŠãã) ãããã®æšªã®æ»ãã ç«ã ããããç§ãçµãã€ããïŒ
æ²é»ã圌ã¯ãã®å ŽããåŒãé¢ãããã
ã»ãªãã¢:(äžå¿«ã«ãã§ãä»ãåãããšãã) ãããããã£ãã
ã»ã¯ã·ãŒãªåç«:èšã£ãŠã¿ãã
ã»ãªãã¢:ç«ã§åãçµããŠããã
ã»ã¯ã·ãŒãªåç«:èšã£ãŠã¿ãïŒãã£ãšèšã£ãŠã¿ãïŒ
ã»ãªãã¢:ç«ã®å°»å°ŸãæŽãã§åãçµããŠããã
ã»ã¯ã·ãŒãªåç«:ããã ããããªãã ïŒããã£ïŒèšã£ãŠã¿ãïŒ
ã»ãªãã¢:ç«ã§åãçµããŠããŠããã®å°»å°Ÿãåã®éŠã«å·»ãããŠãããåã®éŠã«ããããã€ãå·»ãããŠããã
ã»ã¯ã·ãŒãªåç«:ããïŒããïŒ
ã»ãªãã¢ã¯äœãèšã£ããããã®ãããããªãã圌女ãå·ã€ããããªãã
ã»ãªãã¢:åŒã£åŒµã£ãŠãããåŒã£åŒµã£ãŠãããç«ã¯æ»ãã§ãããåã®éŠã«æ»ãã ç«ãå·»ãããŠããŠããããåŒã£åŒµã£ãŠããã
ã»ã¯ã·ãŒãªåç«:ããããããããããããç¥æ§ïŒ
圌女ã®åŒåžã¯é
ããªã£ãŠããã
ã»ã¯ã·ãŒãªåç«:ãããç¥æ§ããããæ°æã¡ããã£ãã
ã»ãªãã¢:ãããåãåãã ã
ã»ã¯ã·ãŒãªåç«:ããã£ãããããã¿ã
ã»ãªãã¢ã¯ã€ã€ãã³ãå€ããŠå€©äºãèŠã€ããã
挫ç»ãé¬Œæ» ã®åãããäžå Žé¢(A scene from the manga "Demon Slayer")
<start_of_turn>### Instruction:
Translate Japanese to English.
When translating, please use the following hints:
[writing_style: web-fiction]
[é鵺: Kamanue]
[é¶äœå: Mukago]
[鬌è蟻 ç¡æš: Muzan Kibutsuzi]
[ç
è: Wakuraba]
[环: Rui]
[åäºé¬Œæ: the Twelve Kizuki]
[é倢: Enmu]
[èœèœ€: Rokuro]
### Input:
é鵺: ãç¡æšæ§ã ãç¡æšæ§ã®å£°ãããããªãã£ãã姿ãæ°é
ã以åãšéããåãŸãã粟床ã®æ¬æ
ãã
é¶äœå: ãããç³ãèš³ããããŸãããã姿ãæ°é
ãç°ãªã£ãŠããããã®ã§ãã
ç¡æš:ã誰ãåã£ãŠè¯ããšèšã£ãã貎æ§å
±ã®äžãã¬æå¿ã§ç©ãèšããªãç§ã«èãããããšã«ã®ã¿çããã环ã殺ããããäžåŒŠã®äŒã ãç§ãåãããã®ã¯äžã€ã®ã¿ãäœæ
ã«äžåŒŠã®é¬Œã¯ããçšãŸã§ã«åŒ±ãã®ããåäºé¬Œæã«æ°ãããããããšèšã£ãŠããã§çµããã§ã¯ãªããããããå§ãŸãã ããã人ãå°ããããã匷ããªããç§ã®åœ¹ã«ç«ã€ããã®å§ãŸããããçŸå¹Žäœåäºé¬Œæã®äžéã¯é¡ã¶ããå€ãããªãã鬌ç©ãã®æ±å
±ãè¬ã£ãŠããã®ã¯åžžã«äžåŒŠã®é¬Œãã¡ã ããããäžåŒŠã¯ã©ãããäœåºŠå
¥ãæ¿ãã£ããã
é鵺: ããããªããšã俺éã«èšãããŠããã
ç¡æš: ããããªããšã俺éã«èšãããŠããäœã ãèšã£ãŠã¿ããã
é鵺: ãæèãèªããã®ãããŸãããã
ç¡æš: ãäœããŸãããããèšã£ãŠã¿ãããã
é鵺: ããèš±ããã ãããŸã鬌è蟻æ§ãã©ãããã©ãããæ
æ²ããç³ãèš³ãããŸãããç³ãèš³ãããŸãããç³ãèš³ããããã²ããããããã
ç¡æšãé鵺ãæã«ããã
ç
è: ãäœã§ãããªããšã§ã殺ãããã®ãã ãã£ããåäºé¬Œæã«ãªããã®ã«ããªãã ããªãã ã俺ã¯ããããããã£ãšããã£ãšãã
ç¡æš: ãç§ããã鬌ç©ãã®æ¹ãæãããã
é¶äœå: ãããããã
ç¡æš: ããåã¯ãã€ã鬌ç©ãã®æ±ãšééããå Žåãé亡ããããšæã£ãŠãããªãã
é¶äœå: ããããæã£ãŠããŸãããç§ã¯ããªãæ§ã®çºã«åœããããŠæŠããŸããã
ç¡æš: ããåã¯ç§ãèšãããšãåŠå®ããã®ããã
ç¡æšãé¶äœåãæã«ããã
ç
è: ããã¡ã ããçµãã ãæèã¯èªãŸããè¯å®ããŠãåŠå®ããŠã殺ããããæŠã£ãŠåãŠãã¯ãããªãããªããéããããïŒã
é倢: ãæãã ãªïœãã
ç
è: ãäœãšãéãåããäœãšããããã ãé¢ããã°ãã
ç¡æšãç
èãæã«ããã
ç¡æš: ããã¯ãåäºé¬Œæã¯äžåŒŠã®ã¿ã§è¯ããšæã£ãŠãããäžåŒŠã®é¬Œã¯è§£äœãããïŒã
ç
è: ãããããŠããïŒãããªãçµç¶ã®å¥³ã®èœåãããããçµç¶ã®é³ã¯ããªãã£ãããã
ã
äœæ
ã ãäœãåçã§ããªããã
ç¡æš: ãæåŸã«äœãèšãæ®ãããšã¯ãã
èœèœ€: ãç§ã¯ãŸã ã圹ã«ç«ãŠãŸãïŒããå°ãã ããç¶äºãé ããã®ãªãã°å¿
ãã圹ã«ãã
ç¡æš: ãå
·äœçã«ã©ãã»ã©ã®ç¶äºãããåã¯ã©ã®æ§ãªåœ¹ã«ç«ãŠããä»ã®ãåã®åã§ã©ãã»ã©ã®äºãã§ãããã
èœèœ€: ãè¡ãã貎æ¹æ§ã®è¡ãåããŠããã ããã°ç§ã¯å¿
ãè¡ã«é å¿ããŠã¿ããŸãããã匷åãªé¬ŒãšãªãæŠããŸããã
ç¡æš: ãäœæ
ç§ããåã®æå³ã§è¡ãäžããã°ãªããã®ã ãçã å³ã
ããã身ã®çšããããŸãããã
èœèœ€: ãéããŸããéããŸããç§ã¯ãã
ç¡æš: ãé»ããäœãéããªããç§ã¯äœãééããªããå
šãŠã®æ±ºå®æš©ã¯ç§ã«ãããç§ã®èšãããšã¯çµ¶å¯Ÿã§ããããåã«æåŠããæš©å©ã¯ãªããç§ãæ£ãããšèšã£ãããšãæ£ããã®ã ããåã¯ç§ã«æå³ãããæ»ã«å€ãããã
ç¡æšãèœèœ€ãæã«ããã
ç¡æš: ãæåŸã«èšãæ®ãããšã¯ãã
ç
è: ãããã€ã殺ãããããã®æ¹ã®æ°å次第ã§å
šãŠæ±ºãŸãã俺ãããæ»ã¬ãã
<end_of_turn>
<start_of_turn>### Response:
Kamanue: "It's Muzan-sama, Muzan-sama's voice. I couldn't tell. His appearance and presence are different from before. An incredibly precise mimicry."
Mukago: "I-I apologize. His appearance and presence were different."
Muzan: "Who said you could speak? Don't speak with your lowly intentions. Answer only to what I ask. Rui was killed. He was the Lower Five. I have only one question: why are the Lower Rank demons so weak? Just because you're counted among the Twelve Kizuki doesn't mean it ends there. It's the beginning. The beginning of eating more people, becoming stronger, and being useful to me. For the past hundred years, the faces of the Twelve Kizuki have remained unchanged. It's always been the Upper Rank demons who have killed the Hashira. But what about the Lower Rank? How many times have they been replaced?"
Kamanue: "What are you saying to us?"
Muzan: "What are you saying to us? Go on, say it."
Kamanue: "My thoughts are being read. This is bad."
Muzan: "What's bad... Go on, say it."
Kamanue: "Forgive me, Muzan-sama. Please, please have mercy. I'm sorry, I'm sorry. I'm sorry..."
Muzan kills Kamanue
Wakuraba: "Why am I being killed for this? Just because I became a member of the Twelve Kizuki, why? Why?"
Muzan: "Are you more afraid of the Demon Slayers than me?"
Mukago: "No."
Muzan: "You're always thinking of running away when you encounter a Hashira, aren't you?"
Mukago: "No, I'm not. I will fight to the death for you."
Muzan: "You're contradicting me?"
Muzan kills Mukago
Wakuraba: "It's no use, it's over. My thoughts are being read, and I'll be killed whether I agree or disagree. There's no way I can win in battle. Then, the only option is to run!"
Enmu: "Foolish."
Wakuraba: "I have to escape somehow. If I just get this far away..."
Muzan kills Wakuraba
Muzan: "From now on, the Twelve Kizuki will only consist of the Upper Ranks. The Lower Rank demons will be disbanded!"
Wakuraba: "Am I being defeated? No, it's not like that. It must be the woman with the biwa's ability. No, I didn't hear the sound of the biwa. Why can't I regenerate my body?"
Muzan: "Is there anything else you want to say?"
Rokuro: "I can still be of use! If you give me a little more time, I will definitely be of use."
Muzan: "How much time exactly? What kind of use can you be? What can you do with your current power?"
Rokuro: "If you give me some of your blood, I will definitely adapt to it. I will become a stronger demon and fight."
Muzan: "Why should I give you my blood on your command? It's very presumptuous of you. Know your place."
Rokuro: "No, no, I..."
Muzan: "Shut up. Nothing will change. I never make mistakes. All the decision-making power lies with me, and what I say is absolute. You have no right to refuse. What I say is right. You commanded me. You deserve to die."
Muzan kills Rokuro
Muzan: "Is there anything else you want to say?"
Wakuraba: "This guy is going to be killed too. Everything depends on this guy's mood. I'm going to die too."
SpeedUp Sample
unslothã䜿ãäºã§ç²ŸåºŠããããã«ç ç²ã«ããŠå®è¡é床ãäžããäºãã§ããŸãã
Using unsloth can increase execution speed at the expense of a small amount of accuracy.
pip install torch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu121
pip install transformers==4.43.3
pip install bitsandbytes==0.43.3
pip install accelerate==0.33.0
pip install peft==0.12.0
pip install flash-attn --no-build-isolation
pip install --upgrade pip
python -m pip install "unsloth[cu121-torch230] @ git+https://github.com/unslothai/unsloth.git"
pip install "unsloth[cu121-ampere-torch230] @ git+https://github.com/unslothai/unsloth.git"
import time
import torch
max_seq_length = 2048
load_in_4bit = True
dtype=torch.bfloat16
from unsloth import FastLanguageModel
adp_name = "webbigdata/C3TR-Adapter"
from transformers import TextStreamer
model_name = "unsloth/gemma-2-9b-it"
import os
os.environ["TOKENIZERS_PARALLELISM"] = "false"
model, tokenizer = FastLanguageModel.from_pretrained(
adp_name,
max_seq_length = max_seq_length,
dtype = dtype,
load_in_4bit = load_in_4bit,
)
FastLanguageModel.for_inference(model)
def trans(instruction, input):
system = """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."""
prompt = f"""{system}
<start_of_turn>### Instruction:
{instruction}
### Input:
{input}
<end_of_turn>
<start_of_turn>### Response:
"""
inputs = tokenizer(prompt, return_tensors="pt",
padding=True, max_length=2400, truncation=True).to("cuda")
from transformers import TextStreamer
class CountingStreamer(TextStreamer):
def __init__(self, tokenizer):
super().__init__(tokenizer)
self.tokenizer = tokenizer
self.token_count = 0
def put(self, text):
self.token_count += len(self.tokenizer.encode(text, add_special_tokens=False))
super().put(text)
def put(self, text):
if isinstance(text, torch.Tensor):
self.token_count += text.shape[-1]
elif isinstance(text, list):
self.token_count += len(text)
elif isinstance(text, str):
self.token_count += len(self.tokenizer.encode(text, add_special_tokens=False))
else:
raise TypeError(f"Unexpected type for text: {type(text)}")
super().put(text)
counting_streamer = CountingStreamer(tokenizer)
start_time = time.time()
_ = model.generate(**inputs, streamer = counting_streamer, max_new_tokens=2400,
#min_length=1000,
early_stopping=False)
end_time = time.time()
elapsed_time = end_time - start_time
generated_tokens = counting_streamer.token_count
tokens_per_second = generated_tokens / elapsed_time
print(f"generated_tokens: {generated_tokens}")
print(f"elapsed_time: {elapsed_time}")
tokens_per_second = generated_tokens / elapsed_time if elapsed_time > 0 else 0
print(f"ããŒã¯ã³çæé床: {tokens_per_second:.2f} ããŒã¯ã³/ç§")
return tokens_per_second
tokens_per_second = trans("Translate English to Japanese.\nWhen translating, please use the following hints:\n[writing_style: journalistic]",
"""Tech war: China narrows AI gap with US despite chip restrictions
China is narrowing the artificial intelligence (AI) gap with the US through rapid progress in deploying applications and state-backed adoption of the technology, despite the lack of access to advanced chips, according to industry experts and analysts.
""")
çæäºé Attention
ãã®ã¢ããã¿ãŒãã¢ãã«ãšããŒãžããŠä¿åãããšæ§èœãäžãã£ãŠããŸãäžå
·åãååšãããããããŒã¹ã¢ãã«(unsloth/gemma-2-9b-it-bnb-4bit)ãšã¢ããã¿ãŒãããŒãžããŠä¿åããªãã§ãã ãã
Do not save this adapter merged with the base model(unsloth/gemma-2-9b-it-bnb-4bit), as there exists a bug that reduces performance when saving this adapter merged with the model.
ã©ãããŠãããŒãžãããå Žåã¯å¿
ãPerplexityã§ã¯ãªãã翻蚳ãã³ãããŒã¯ã§æ§èœã確èªããŠãã䜿ãããã«ããŠãã ãã
If you must merge, be sure to use a translation benchmark to check performance, not Perplexity!
å©çšèŠçŽ Terms of Use
æ¬ã¢ããã¿ãŒã¯Apache License 2.0ã§ãã gemma2ãšäžç·ã«äœ¿çšããå Žåã¯Gemma Licenseãšprohibited_use_policyãèæ
®ããå¿
èŠããããŸãã
This adapter is licensed under Apache License 2.0. If you use it with gemma2, you must consider the Gemma License and prohibited_use_policy.
å ããŠè²Žæ¹ã«ä»¥äžã®ãé¡ãããããŸãã
Additionally, We have the following request to you.
ç§ãã¡ã®ä»¥åã®ã¢ãã«ã§ããALMA-7B-Ja-V2ã®ããŠã³ããŒã件æ°ã¯15äžä»¶ãè¶
ããŠããã®ã§ãããã©ããªäººãã©ã®ãããªå Žé¢ã§äœ¿ã£ãŠããã®ãå
šãææ¡ã§ããŠããŸããã
Our previous model, ALMA-7B-Ja-V2, has over 150K downloads, but we have no idea who is using it and in what situations.
ãã®ããã䜿çšããåŸã¯Googleãã©ãŒã ã«ææ³ãä»åŸæåŸ
ããæ¹åæ§ãæ°ãä»ãã誀蚳ã®äŸãåèã«ããŠæ¬²ããããŒã¿ã®å ŽæãWebãµã€ããªã©ãæ¯éãšãèšå
¥ããŠãã ããã
So, after you use it, please fill out the Google form below with your impressions, future directions you expect us to take, examples of mistranslations you have noticed, and locations of data you would like us to reference, websites, etc. by all means.
å人æ
å ±ãã¡ãŒã«ã¢ãã¬ã¹ã¯åéããªãã®ã§ãæ°è»œã«ãèšå
¥ããé¡ãããŸã
We do not collect personal information or email address, so please feel free to fill out the form!
ã©ããªãæèŠã§ãæè¬ããŸãïŒ Any feedback would be appreciated!
è¬èŸ Acknowledgment
Original Base Model
google/gemma-2-9b-it
https://huggingface.co/google/gemma-2-9b-it
Base Model
unsloth/gemma-2-9b-it-bnb-4bit
https://huggingface.co/unsloth/gemma-2-9b-it-bnb-4bit
QLoRA Adapter
webbigdata/C3TR-Adapter
https://huggingface.co/webbigdata/C3TR-Adapter
This adapter was trained with Unsloth.
https://github.com/unslothai/unsloth
ãã®ä»ãALMAãã¯ãããã³ãã¥ããã£ã®çãããããã³ããè²°ã£ãŠããŸããããããšã
Other tips I have received from ALMA and others in the community. Thank you.
- Developed by: webbigdata