Views
No views yet

| Tokenizer | Size | Zh | En | Code | Math | Average |
|---|---|---|---|---|---|---|
| Aquila2-original | 100k | 4.70 | 4.42 | 3.20 | 3.77 | 4.02 |
| Qwen1.5 | 151k | 4.27 | 4.51 | 3.62 | 3.35 | 3.94 |
| Llama3 | 128k | 3.45 | 4.61 | 3.77 | 3.88 | 3.93 |
| Aquila2-new | 143k | 4.60 | 4.61 | 3.78 | 3.88 | 4.22 |
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3from transformers import BitsAndBytesConfig
4
5device= "cuda:0"
6
7# Model Name
8model_name = 'BAAI/Aquila2-7B'
9
10# load model and tokenizer
11quantization_config=BitsAndBytesConfig(
12 load_in_4bit=True,
13 bnb_4bit_use_double_quant=True,
14 bnb_4bit_quant_type="nf4",
15 bnb_4bit_compute_dtype=torch.bfloat16,
16 )
17model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, trust_remote_code=True,
18 # quantization_config=quantization_config # Uncomment this one for 4-bit quantization
19 )
20
21tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True)
22
23model.eval()
24
25model.to(device)
26
27# Example
28text = "The meaning of life is"
29tokens = tokenizer.encode_plus(text)['input_ids']
30tokens = torch.tensor(tokens)[None,].to(device)
31
32with torch.no_grad():
33 out = model.generate(tokens, do_sample=False, max_length=128, eos_token_id=tokenizer.eos_token_id)[0]
34 out = tokenizer.decode(out.cpu().numpy().tolist())
35 print(out)