harpreetsahota commited on
Commit
1fb44f8
1 Parent(s): b0b6c53

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +29 -7
README.md CHANGED
@@ -43,19 +43,41 @@ The model is intended for commercial and research use in English.
43
 
44
  Use the code below to get started with the model.
45
 
46
- ```bibtex
47
  import torch
48
- from transformers import AutoModelForCausalLM, AutoTokenizer
49
 
50
  model_name = "Deci/DeciLM-7B-instruct"
 
51
  device = "cuda" # for GPU usage or "cpu" for CPU usage
52
 
53
- tokenizer = AutoTokenizer.from_pretrained(model_name)
54
- model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, trust_remote_code=True).to(device)
 
 
55
 
56
- inputs = tokenizer.encode("In a shocking finding, scientists discovered a herd of unicorns living in", return_tensors="pt").to(device)
57
- outputs = model.generate(inputs, max_new_tokens=100, do_sample=True, top_p=0.95)
58
- print(tokenizer.decode(outputs[0]))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  ```
60
 
61
  ## Evaluation
 
43
 
44
  Use the code below to get started with the model.
45
 
46
+ ```python
47
  import torch
48
+ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig, pipeline
49
 
50
  model_name = "Deci/DeciLM-7B-instruct"
51
+
52
  device = "cuda" # for GPU usage or "cpu" for CPU usage
53
 
54
+ bnb_config = BitsAndBytesConfig(
55
+ load_in_4bit = True,
56
+ bnb_4bit_compute_dtype=torch.bfloat16
57
+ )
58
 
59
+ model = AutoModelForCausalLM.from_pretrained(
60
+ model_name,
61
+ device_map="auto",
62
+ trust_remote_code=True,
63
+ quantization_config=bnb_config
64
+ )
65
+
66
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
67
+ tokenizer.pad_token = tokenizer.eos_token
68
+
69
+ deci_generator = pipeline("text-generation",
70
+ model=model,
71
+ tokenizer=tokenizer,
72
+ temperature=0.1,
73
+ device_map="auto",
74
+ max_length=4096,
75
+ return_full_text=False
76
+ )
77
+
78
+ prompt = "How do I make the most delicious pancakes the world has ever tasted?"
79
+ response = deci_generator(prompt)[0]['generated_text']
80
+ print(response)
81
  ```
82
 
83
  ## Evaluation