shuvom commited on
Commit
d25e8dc
1 Parent(s): 421429e

usage update

Browse files
Files changed (1) hide show
  1. README.md +23 -16
README.md CHANGED
@@ -42,25 +42,32 @@ dtype: float16
42
 
43
  ## 💻 Usage
44
 
45
- ```python
46
- !pip install -qU transformers accelerate
47
 
48
- from transformers import AutoTokenizer
49
- import transformers
 
 
 
 
 
 
 
 
 
50
  import torch
51
 
52
- model = "shuvom/yuj-v1"
53
- messages = [{"role": "user", "content": "some hindi texts"}]
 
 
 
 
54
 
55
- tokenizer = AutoTokenizer.from_pretrained(model)
56
- prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
57
- pipeline = transformers.pipeline(
58
- "text-generation",
59
- model=model,
60
- torch_dtype=torch.float16,
61
- device_map="auto",
62
- )
63
 
64
- outputs = pipeline(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
65
- print(outputs[0]["generated_text"])
 
66
  ```
 
42
 
43
  ## 💻 Usage
44
 
45
+ First, you need to install some of below packages:
 
46
 
47
+ 1. Bits and bytes
48
+ ```python
49
+ !pip install bitsandbytes
50
+ ```
51
+ 2. Accelerate (to install the latest version)
52
+ ```python
53
+ !pip install git+https://github.com/huggingface/accelerate.git
54
+ ```
55
+ 3. Usage
56
+ ```python
57
+ # Usage
58
  import torch
59
 
60
+ # Load model directly
61
+ from transformers import AutoTokenizer, AutoModelForCausalLM
62
+
63
+ # load the model in 4-bit quantization
64
+ tokenizer = AutoTokenizer.from_pretrained("shuvom/yuj-v1")
65
+ model = AutoModelForCausalLM.from_pretrained("shuvom/yuj-v1",torch_dtype=torch.bfloat16,load_in_4bit=True)
66
 
67
+ prompt = "युज शीर्ष द्विभाषी मॉडल में से एक है"
68
+ inputs = tokenizer(prompt, return_tensors="pt")
 
 
 
 
 
 
69
 
70
+ # Generate
71
+ generate_ids = model.generate(inputs.input_ids, max_length=65)
72
+ tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
73
  ```