Update README.md
Browse files
README.md
CHANGED
|
@@ -43,4 +43,40 @@ My model is now on the Arabic leaderboard.
|
|
| 43 |
|
| 44 |
Please refer to https://github.com/Slim205/Arabicllm/ for more details.
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
# Feel free to use this model and send me your feedback. Together, we can advance Arabic LLM development!
|
|
|
|
| 43 |
|
| 44 |
Please refer to https://github.com/Slim205/Arabicllm/ for more details.
|
| 45 |
|
| 46 |
+
# Using the Model
|
| 47 |
+
|
| 48 |
+
The model uses `transformers` to generate responses based on the provided inputs. Here’s an example code to use the model:
|
| 49 |
+
|
| 50 |
+
```python
|
| 51 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 52 |
+
from peft import PeftModel
|
| 53 |
+
import torch
|
| 54 |
+
|
| 55 |
+
model_id = "google/gemma-2-2b-it"
|
| 56 |
+
peft_model_id = "Slim205/Barka-2b-it"
|
| 57 |
+
|
| 58 |
+
model = AutoModelForCausalLM.from_pretrained(model_id).to("cuda")
|
| 59 |
+
tokenizer = AutoTokenizer.from_pretrained("Slim205/Barka-2b-it")
|
| 60 |
+
model1 = PeftModel.from_pretrained(model, peft_model_id)
|
| 61 |
+
|
| 62 |
+
input_text = "ما هي عاصمة تونس؟" # "What is the capital of Tunisia?"
|
| 63 |
+
chat = [
|
| 64 |
+
{ "role": "user", "content": input_text },
|
| 65 |
+
]
|
| 66 |
+
|
| 67 |
+
prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
|
| 68 |
+
inputs = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
|
| 69 |
+
outputs = model.generate(
|
| 70 |
+
input_ids=inputs.to(model.device),
|
| 71 |
+
max_new_tokens=32,
|
| 72 |
+
top_p=0.9,
|
| 73 |
+
do_sample=True
|
| 74 |
+
)
|
| 75 |
+
|
| 76 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 77 |
+
```
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
You can adjust any additional sections or formatting as necessary!
|
| 81 |
+
|
| 82 |
# Feel free to use this model and send me your feedback. Together, we can advance Arabic LLM development!
|