Update README.md
Browse files
README.md
CHANGED
|
@@ -35,8 +35,45 @@ This is the model card of a 🤗 transformers model that has been pushed on the
|
|
| 35 |
|
| 36 |
## Uses
|
| 37 |
|
| 38 |
-
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
### Direct Use
|
| 41 |
|
| 42 |
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
|
|
|
| 35 |
|
| 36 |
## Uses
|
| 37 |
|
| 38 |
+
```python
|
| 39 |
|
| 40 |
+
|
| 41 |
+
%%time
|
| 42 |
+
|
| 43 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 44 |
+
|
| 45 |
+
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2b")
|
| 46 |
+
|
| 47 |
+
from peft import PeftModel
|
| 48 |
+
model_name='google/gemma-2b'
|
| 49 |
+
inference_model = AutoModelForCausalLM.from_pretrained(
|
| 50 |
+
model_name,
|
| 51 |
+
low_cpu_mem_usage=True,
|
| 52 |
+
# use_flash_attention_2=True,
|
| 53 |
+
|
| 54 |
+
)
|
| 55 |
+
inference_model.resize_token_embeddings(len(tokenizer))
|
| 56 |
+
|
| 57 |
+
inference_model = PeftModel.from_pretrained(inference_model, "hemanthkandimalla/HemanthLLM_tiny1.1b")
|
| 58 |
+
|
| 59 |
+
inference_model.eval()
|
| 60 |
+
text="attacks names"
|
| 61 |
+
tokenizer_input=tokenizer(text=text, return_tensors="pt")
|
| 62 |
+
output_tokens = inference_model.generate(
|
| 63 |
+
**tokenizer_input,
|
| 64 |
+
max_new_tokens=256,
|
| 65 |
+
do_sample=True,
|
| 66 |
+
temperature=0.2,
|
| 67 |
+
top_p=0.95,
|
| 68 |
+
top_k=50,
|
| 69 |
+
eos_token_id=tokenizer.eos_token_id,
|
| 70 |
+
pad_token_id=tokenizer.pad_token_id,
|
| 71 |
+
)
|
| 72 |
+
text=tokenizer.decode(output_tokens[0], skip_special_tokens=False)
|
| 73 |
+
|
| 74 |
+
print(text)
|
| 75 |
+
|
| 76 |
+
```
|
| 77 |
### Direct Use
|
| 78 |
|
| 79 |
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|