Fix the code markdown formatting of README

#1
by hululuzhu - opened
Files changed (1) hide show
  1. README.md +20 -11
README.md CHANGED
@@ -1,20 +1,29 @@
1
  ### Import from Transformers
2
  To load the Moss 7B model using Transformers, use the following code:
 
3
  ```python
4
- >>> from transformers import AutoTokenizer, AutoModelForCausalLM
5
- >>> tokenizer = AutoTokenizer.from_pretrained("fnlp/moss-base-7b", trust_remote_code=True)
6
- >>> model = AutoModelForCausalLM.from_pretrained("fnlp/moss-base-7b", trust_remote_code=True).cuda()
7
- >>> model = model.eval()
8
- >>> inputs = tokenizer(["流浪地球的导演是"], return_tensors="pt")
9
- >>> for k,v in inputs.items():
10
- inputs[k] = v.cuda()
11
- >>> outputs = model.generate(**inputs, do_sample=True, temperature=0.8, top_p=0.8, repetition_penalty=1.1, max_new_tokens=256)
12
- >>> response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
13
- >>> print(response)
 
 
 
 
 
 
14
  郭帆
15
  主演分别是吴京和屈楚萧 还有李光洁刘德华等等
16
  这电影可以说是目前国内科幻片的天花板了
17
  票房也是突破50亿大关啦
18
  小编真的非常期待这部电影呀
19
  所以呢今天就给大家整理了关于影片中的很多细节图哦~
20
- 不知道大家有没有注意到呢
 
 
 
1
  ### Import from Transformers
2
  To load the Moss 7B model using Transformers, use the following code:
3
+
4
  ```python
5
+ # If seeing sentencepiece error: $ pip install sentencepiece
6
+ from transformers import AutoTokenizer, AutoModelForCausalLM
7
+ tokenizer = AutoTokenizer.from_pretrained("fnlp/moss-base-7b",
8
+ trust_remote_code=True)
9
+ model = AutoModelForCausalLM.from_pretrained("fnlp/moss-base-7b",
10
+ trust_remote_code=True).cuda()
11
+ model = model.eval()
12
+ inputs = tokenizer(["流浪地球的导演是"], return_tensors="pt")
13
+ for k,v in inputs.items():
14
+ inputs[k] = v.cuda()
15
+ outputs = model.generate(**inputs, do_sample=True, temperature=0.8, top_p=0.8,
16
+ repetition_penalty=1.1, max_new_tokens=256)
17
+ response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:],
18
+ skip_special_tokens=True)
19
+ print(response)
20
+ """
21
  郭帆
22
  主演分别是吴京和屈楚萧 还有李光洁刘德华等等
23
  这电影可以说是目前国内科幻片的天花板了
24
  票房也是突破50亿大关啦
25
  小编真的非常期待这部电影呀
26
  所以呢今天就给大家整理了关于影片中的很多细节图哦~
27
+ 不知道大家有没有注意到呢
28
+ """
29
+ ```