wygbb commited on
Commit
9ceab5a
·
verified ·
1 Parent(s): 73edb86

Delete README.md

Browse files
Files changed (1) hide show
  1. README.md +0 -63
README.md DELETED
@@ -1,63 +0,0 @@
1
- ---
2
- license: apache-2.0
3
- datasets:
4
- - w8ay/security-paper-datasets
5
- - TigerResearch/tigerbot-zhihu-zh-10k
6
- pipeline_tag: text-generation
7
- ---
8
-
9
- Github: https://github.com/Clouditera/secgpt
10
-
11
- ## 使用
12
- 商业模型对于网络安全领域问题大多会有道德限制,所以基于网络安全数据训练了一个模型,模型基于Baichuan 13B,模型参数大小130亿,至少需要30G显存运行,35G最佳。
13
- - transformers
14
- - peft
15
-
16
- **模型加载**
17
- ```python
18
- from transformers import AutoModelForCausalLM, AutoTokenizer
19
- import torch
20
- from peft import PeftModel
21
- device = 'auto'
22
- tokenizer = AutoTokenizer.from_pretrained("w8ay/secgpt", trust_remote_code=True)
23
- model = AutoModelForCausalLM.from_pretrained("w8ay/secgpt",
24
- trust_remote_code=True,
25
- device_map=device,
26
- torch_dtype=torch.float16)
27
- print("模型加载成功")
28
-
29
- ```
30
- **调用**
31
- ```python
32
- def reformat_sft(instruction, input):
33
- if input:
34
- prefix = (
35
- "Below is an instruction that describes a task, paired with an input that provides further context. "
36
- "Write a response that appropriately completes the request.\n"
37
- f"### Instruction:\n{instruction}\n\n### Input:\n{input}\n\n### Response:"
38
- )
39
- else:
40
- prefix = (
41
- "Below is an instruction that describes a task. "
42
- "Write a response that appropriately completes the request.\n"
43
- f"### Instruction:\n{instruction}\n\n### Response:"
44
- )
45
- return prefix
46
-
47
- query = '''介绍sqlmap如何使用'''
48
- query = reformat_sft(query,'')
49
-
50
- generation_kwargs = {
51
- "top_p": 0.7,
52
- "temperature": 0.3,
53
- "max_new_tokens": 2000,
54
- "do_sample": True,
55
- "repetition_penalty":1.1
56
- }
57
-
58
- inputs = tokenizer.encode(query, return_tensors='pt', truncation=True)
59
- inputs = inputs.cuda()
60
- generate = model.generate(input_ids=inputs, **generation_kwargs)
61
- output = tokenizer.decode(generate[0])
62
- print(output)
63
- ```