Update README.md
Browse files
README.md
CHANGED
@@ -40,3 +40,38 @@ The typed schema is :
|
|
40 |
schema = ['事件', '自然科学', '建筑结构', '地理地区', '组织', '医学', '天文对象', '人造物件', '运输', '作品', '生物', '人物']
|
41 |
```
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
schema = ['事件', '自然科学', '建筑结构', '地理地区', '组织', '医学', '天文对象', '人造物件', '运输', '作品', '生物', '人物']
|
41 |
```
|
42 |
|
43 |
+
Try the following case:
|
44 |
+
|
45 |
+
```python
|
46 |
+
cat_char = '🐱'
|
47 |
+
bot_char = '🤖'
|
48 |
+
instruction ='你是一个图谱实体知识结构化专家。请从input中抽取出符合schema定义的实体实例和其属性,不存在的属性不输出,属性存在多值就返回列表。请按照JSON字符串的格式回答。'
|
49 |
+
schema = schemas['人物']
|
50 |
+
input_text = "个人简介姓名:拉塞·维比 所属球队:布伦特福德 国籍:丹麦、法国、荷兰、法属圭亚那 出生日期:1987-02-22 身高:181cm 体重:73kg 场上位置:前锋 球衣号码:21 丹麦射手拉塞-维比,获得了2014赛季瑞超联赛金靴"
|
51 |
+
input_text = {'input': input_text, 'schema': schema}
|
52 |
+
input_text = json.dumps(input_text).decode('UTF-8')
|
53 |
+
ctx = f'{cat_char}:{instruction}\n{input_text}\n{bot_char}:'
|
54 |
+
print(ctx)
|
55 |
+
|
56 |
+
def my_print(s):
|
57 |
+
print(s, end='', flush=True)
|
58 |
+
|
59 |
+
# For alpha_frequency and alpha_presence, see "Frequency and presence penalties":
|
60 |
+
# https://platform.openai.com/docs/api-reference/parameter-details
|
61 |
+
|
62 |
+
args = PIPELINE_ARGS(temperature = 1.0, top_p = 0, top_k = 0, # top_k = 0 then ignore
|
63 |
+
alpha_frequency = 0.25,
|
64 |
+
alpha_presence = 0.25,
|
65 |
+
alpha_decay = 0.996, # gradually decay the penalty
|
66 |
+
token_ban = [0], # ban the generation of some tokens
|
67 |
+
token_stop = [0,1], # stop generation whenever you see any token here
|
68 |
+
chunk_len = 256) # split input into chunks to save VRAM (shorter -> slower)
|
69 |
+
|
70 |
+
pipeline.generate(ctx, token_count=200, args=args, callback=my_print,state=states_value)
|
71 |
+
print('\n')
|
72 |
+
```
|
73 |
+
|
74 |
+
The output should look like:
|
75 |
+
```bash
|
76 |
+
{"result":人物}
|
77 |
+
```
|