File size: 2,987 Bytes
48052d5
 
 
 
 
a01d5f2
 
64e55b6
 
 
 
 
 
 
 
 
 
 
d3853e6
64e55b6
 
 
 
 
 
 
 
48052d5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
language:
- zh
---

# 🤭 Please refer to https://github.com/svjack/Genshin-Impact-Character-Instruction to get more info

## Brief introduction

### BackGround
[Genshin Impact](https://genshin.hoyoverse.com/en/) is an action role-playing game developed by miHoYo, published by miHoYo in mainland China and worldwide by Cognosphere, 
HoYoverse. The game features an anime-style open-world environment and an action-based battle system using elemental magic and character-switching. 

In the Game, one can play many Characters to explore the amazing open-world environment.

<br/>

<div align="center">
<img src="imgs/Collei.jpg" alt="Girl in a jacket" width="256" height="512"> 
</div>

<br/>

Below is the demo to generate response from Collei (柯莱),

More Info can be found in [svjack/Genshin-Impact-Character-Instruction](https://github.com/svjack/Genshin-Impact-Character-Instruction)

Install Following Library
```bash
pip install llama-cpp-python
pip install transformers
pip install sentencepiece
pip install protobuf
```

Use llama-cpp to generate 
```python
import llama_cpp
import llama_cpp.llama_tokenizer

llama = llama_cpp.Llama.from_pretrained(
    repo_id="svjack/genshin_impact_character_llamazh13b_ggml",
    filename="llama2zh-13b-3900-q4_0.gguf",
    tokenizer=llama_cpp.llama_tokenizer.LlamaHFTokenizer.from_pretrained("hfl/chinese-llama-2-13b"),
    verbose=False,
    n_gpu_layers = -1
)

response = llama.create_chat_completion(
    messages=[
        {
            "role": "user",
            "content": '''
            下面是柯莱的一些基本信息
            性别:少女女性
            国籍:须弥
            身份:化城郭见习巡林员
            性格特征:善解人意,乐于助人
            这些是一段角色介绍
            「乐于助人」、「阳光善良」、「热情洋溢」⋯在化城郭内外稍加了解,就能听到人们对这位见习巡林员的称赞。
            只要身体允许,无论学业如何繁忙,柯莱都不会怠慢巡林工作,更不吝于向各色行人伸出饱含热情的援手。
            只是如此热诚积极的柯莱,似乎也有着不愿为人所知的过往与心事。
            假如在她经常巡逻的林间,发现贴满奇怪字条的树洞,或是类似碎碎念的声响。
            无论看到听到了什么,还请善解人意地绕道而行,权当作兰那罗开的小小玩笑。
            毕竟有些琐事,是只能说与树洞听的一一至少目前还是。
            柯莱如何评价巡林员的工作?
            '''
        }
    ],
    stream=True
)
for chunk in response:
    delta = chunk["choices"][0]["delta"]
    if "content" not in delta:
        continue
    print(delta["content"], end="", flush=True)
print()
```

Output
```txt
「巡林」…听起来像是很神圣又很有威信的职业吧!不过我本人却只是一名见习巡林员而已,真想多向前辈请教一些东西呢。
```