ldwang commited on
Commit
5fd4dea
1 Parent(s): d11d77e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +12 -20
README.md CHANGED
@@ -14,11 +14,11 @@ license: other
14
  </h4>
15
 
16
 
17
- We opensource our **Aquila2** series, now including **Aquila2**, the base language models, namely **Aquila2-7B** and **Aquila2-34B**, as well as **AquilaChat2**, the chat models, namely **AquilaChat2-7B** and **AquilaChat2-34B**, as well as the long-text chat models, namely **AquilaChat2-7B-16k** and **AquilaChat2-34B-16k**
18
 
19
  The additional details of the Aquila model will be presented in the official technical report. Please stay tuned for updates on official channels.
20
 
21
- ## Quick Start AquilaChat2-7B(Chat model)
22
 
23
  ### 1. Inference
24
 
@@ -27,29 +27,21 @@ import torch
27
  from transformers import AutoTokenizer, AutoModelForCausalLM
28
  from transformers import BitsAndBytesConfig
29
 
30
- device = torch.device("cuda:0")
31
- model_info = "BAAI/AquilaChat2-7B"
32
  tokenizer = AutoTokenizer.from_pretrained(model_info, trust_remote_code=True)
33
- quantization_config=BitsAndBytesConfig(
34
- load_in_4bit=True,
35
- bnb_4bit_use_double_quant=True,
36
- bnb_4bit_quant_type="nf4",
37
- bnb_4bit_compute_dtype=torch.bfloat16,
38
- )
39
- model = AutoModelForCausalLM.from_pretrained(model_info, trust_remote_code=True, torch_dtype=torch.float16,
40
- # quantization_config=quantization_config, # Uncomment this line for 4bit quantization
41
- )
42
  model.eval()
43
- model.to(device)
44
  text = "请给出10个要到北京旅游的理由。"
45
- from predict import predict
46
- out = predict(model, text, tokenizer=tokenizer, max_gen_len=200, top_p=0.95,
47
- seed=1234, topk=100, temperature=0.9, sft=True, device=device,
48
- model_name="AquilaChat2-7B")
49
- print(out)
 
 
50
  ```
51
 
52
 
53
  ## License
54
 
55
- Aquila2 series open-source model is licensed under [ BAAI Aquila Model Licence Agreement](https://huggingface.co/BAAI/AquilaChat2-7B/blob/main/BAAI-Aquila-Model-License%20-Agreement.pdf)
 
14
  </h4>
15
 
16
 
17
+ We opensource our **Aquila2** series, now including **Aquila2**, the base language models, namely **Aquila2-7B**, **Aquila2-34B** and **Aquila2-70B** , as well as **AquilaChat2**, the chat models, namely **AquilaChat2-7B**, **AquilaChat2-34B** and **AquilaChat2-70B**, as well as the long-text chat models, namely **AquilaChat2-7B-16k** and **AquilaChat2-34B-16k**
18
 
19
  The additional details of the Aquila model will be presented in the official technical report. Please stay tuned for updates on official channels.
20
 
21
+ ## Quick Start
22
 
23
  ### 1. Inference
24
 
 
27
  from transformers import AutoTokenizer, AutoModelForCausalLM
28
  from transformers import BitsAndBytesConfig
29
 
30
+ model_info = "BAAI/Aquila2-70B"
 
31
  tokenizer = AutoTokenizer.from_pretrained(model_info, trust_remote_code=True)
32
+ model = AutoModelForCausalLM.from_pretrained(model_info, trust_remote_code=True)
 
 
 
 
 
 
 
 
33
  model.eval()
 
34
  text = "请给出10个要到北京旅游的理由。"
35
+ tokens = tokenizer.encode_plus(text)['input_ids']
36
+ tokens = torch.tensor(tokens)[None,].to(device)
37
+ stop_tokens = ["###", "[UNK]", "</s>"]
38
+ with torch.no_grad():
39
+ out = model.generate(tokens, do_sample=True, max_length=512, eos_token_id=100007, bad_words_ids=[[tokenizer.encode(token)[0] for token in stop_tokens]])[0]
40
+ out = tokenizer.decode(out.cpu().numpy().tolist())
41
+ print(out)
42
  ```
43
 
44
 
45
  ## License
46
 
47
+ Aquila2 series open-source model is licensed under [ BAAI Aquila Model Licence Agreement](https://huggingface.co/BAAI/Aquila2-7B/blob/main/BAAI-Aquila-Model-License-Agreement.pdf)