Update README.md
Browse files
README.md
CHANGED
|
@@ -1,8 +1,60 @@
|
|
| 1 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
tags:
|
| 3 |
-
-
|
| 4 |
- text-generation
|
|
|
|
|
|
|
| 5 |
---
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
readme_content = """---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
license: llama3
|
| 5 |
+
library_name: transformers
|
| 6 |
tags:
|
| 7 |
+
- nlp
|
| 8 |
- text-generation
|
| 9 |
+
- llama-3
|
| 10 |
+
pipeline_tag: text-generation
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# Llama 3 8B Instruct
|
| 14 |
+
|
| 15 |
+
This repository contains the weights for the Llama 3 8B Instruct model. It is optimized for chat and instruction-following tasks.
|
| 16 |
+
|
| 17 |
+
## Model Details
|
| 18 |
+
- **Architecture:** Llama 3
|
| 19 |
+
- **Size:** 8B Parameters
|
| 20 |
+
- **Type:** Instruction Tuned
|
| 21 |
+
- **Library:** Transformers
|
| 22 |
+
|
| 23 |
+
## How to use
|
| 24 |
+
|
| 25 |
+
You can use this model directly with the Hugging Face `transformers` library:
|
| 26 |
+
|
| 27 |
+
```python
|
| 28 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 29 |
+
import torch
|
| 30 |
+
|
| 31 |
+
model_id = "maherghanem86/llama3"
|
| 32 |
+
|
| 33 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 34 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 35 |
+
model_id,
|
| 36 |
+
torch_dtype=torch.bfloat16,
|
| 37 |
+
device_map="auto"
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
messages = [
|
| 41 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
| 42 |
+
{"role": "user", "content": "Hello, how are you?"},
|
| 43 |
+
]
|
| 44 |
+
|
| 45 |
+
input_ids = tokenizer.apply_chat_template(
|
| 46 |
+
messages,
|
| 47 |
+
add_generation_prompt=True,
|
| 48 |
+
return_tensors="pt"
|
| 49 |
+
).to(model.device)
|
| 50 |
+
|
| 51 |
+
outputs = model.generate(
|
| 52 |
+
input_ids,
|
| 53 |
+
max_new_tokens=256,
|
| 54 |
+
do_sample=True,
|
| 55 |
+
temperature=0.6,
|
| 56 |
+
top_p=0.9,
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
response = outputs[0][input_ids.shape[-1]:]
|
| 60 |
+
print(tokenizer.decode(response, skip_special_tokens=True))
|