File size: 1,795 Bytes
2a0062a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1a3ac47
 
 
 
 
 
 
2a0062a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
---
license: cc-by-nc-sa-4.0
---

prompt格式:
```python
        gpt_dict = [{
          "src": "原文1",
          "dst": "译文1",
          "info": "注释信息1",
        },]
        gpt_dict_text_list = []
        for gpt in gpt_dict:
            src = gpt['src']
            dst = gpt['dst']
            info = gpt['info'] if "info" in gpt.keys() else None
            if info:
                single = f"{src}->{dst} #{info}"
            else:
                single = f"{src}->{dst}"
            gpt_dict_text_list.append(single)

        gpt_dict_raw_text = "\n".join(gpt_dict_text_list)

        user_prompt = "根据以下术语表(可以为空):\n" + gpt_dict_raw_text + "\n" + "将下面的日文文本根据对应关系和备注翻译成中文:" + japanese
        prompt = "<|im_start|>system\n你是一个轻小说翻译模型,可以流畅通顺地以日本轻小说的风格将日文翻译成简体中文,并联系上下文正确使用人称代词,不擅自添加原文中没有的代词。<|im_end|>\n" \ # system prompt
        + "<|im_start|>user\n" + user_prompt + "<|im_end|>\n" \ # user prompt
        + "<|im_start|>assistant\n" # assistant prompt start

        # 如果术语表为空,也可以使用如下prompt(在术语表为空时更加推荐)
        user_prompt = "将下面的日文文本翻译成中文:" + japanese
        prompt = "<|im_start|>system\n你是一个轻小说翻译模型,可以流畅通顺地以日本轻小说的风格将日文翻译成简体中文,并联系上下文正确使用人称代词,不擅自添加原文中没有的代词。<|im_end|>\n" \ # system prompt
        + "<|im_start|>user\n" + user_prompt + "<|im_end|>\n" \ # user prompt
        + "<|im_start|>assistant\n" # assistant prompt start

```