dahara1 commited on
Commit
ccce33d
1 Parent(s): ffc9b0b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +5 -4
README.md CHANGED
@@ -78,7 +78,7 @@ from peft import PeftModel
78
  model_id = "unsloth/gemma-7b-bnb-4bit"
79
  peft_model_id = "webbigdata/C3TR-Adapter"
80
 
81
- model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
82
  model = PeftModel.from_pretrained(model = model, model_id = peft_model_id)
83
  tokenizer = AutoTokenizer.from_pretrained(model_id)
84
  tokenizer.pad_token = tokenizer.unk_token
@@ -89,13 +89,14 @@ def trans(my_str):
89
 
90
  # Translation
91
  generated_ids = model.generate(input_ids=input_ids,
92
- max_new_tokens=800, use_cache=True
 
 
93
  )
94
  full_outputs = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
95
  return full_outputs[0].split("### Response:\n")[-1].strip()
96
 
97
- ret = trans("""
98
- 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.
99
 
100
  ### Instruction:
101
  Translate Japanese to English.
 
78
  model_id = "unsloth/gemma-7b-bnb-4bit"
79
  peft_model_id = "webbigdata/C3TR-Adapter"
80
 
81
+ model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")
82
  model = PeftModel.from_pretrained(model = model, model_id = peft_model_id)
83
  tokenizer = AutoTokenizer.from_pretrained(model_id)
84
  tokenizer.pad_token = tokenizer.unk_token
 
89
 
90
  # Translation
91
  generated_ids = model.generate(input_ids=input_ids,
92
+ max_new_tokens=800, use_cache=True,
93
+ do_sample=True, num_beams=3, temperature=0.5, top_p=0.3,
94
+ repetition_penalty=1.0
95
  )
96
  full_outputs = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
97
  return full_outputs[0].split("### Response:\n")[-1].strip()
98
 
99
+ 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.
 
100
 
101
  ### Instruction:
102
  Translate Japanese to English.