Update README.md
Browse files
README.md
CHANGED
|
@@ -86,34 +86,31 @@ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
|
| 86 |
import torch
|
| 87 |
|
| 88 |
model_name = "MohammedNasser/silma_9b_instruct_ft"
|
|
|
|
| 89 |
|
| 90 |
# Load model and tokenizer
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
model_name,
|
| 94 |
-
torch_dtype=torch.float16,
|
| 95 |
-
device_map="auto",
|
| 96 |
-
)
|
| 97 |
|
| 98 |
# Create pipeline
|
| 99 |
-
|
| 100 |
"text-generation",
|
| 101 |
-
model=
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
temperature=0.7,
|
| 106 |
-
top_p=0.95,
|
| 107 |
-
return_full_text=False
|
| 108 |
)
|
| 109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
# Example usage
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
response = qa_pipeline(prompt)[0]['generated_text']
|
| 114 |
|
| 115 |
-
print(f"Question: {
|
| 116 |
-
print(f"Answer: {
|
| 117 |
```
|
| 118 |
|
| 119 |
## Performance
|
|
|
|
| 86 |
import torch
|
| 87 |
|
| 88 |
model_name = "MohammedNasser/silma_9b_instruct_ft"
|
| 89 |
+
user_question = "إذا كان لديك ثلاث سيارات، وبعت واحدة منها، كم سيارة ستبقى لديك؟"
|
| 90 |
|
| 91 |
# Load model and tokenizer
|
| 92 |
+
import torch
|
| 93 |
+
from transformers import pipeline
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
# Create pipeline
|
| 96 |
+
pipe = pipeline(
|
| 97 |
"text-generation",
|
| 98 |
+
model=model_name,
|
| 99 |
+
torch_dtype= torch.bfloat16,
|
| 100 |
+
device="cuda",
|
| 101 |
+
return_full_text=False,
|
|
|
|
|
|
|
|
|
|
| 102 |
)
|
| 103 |
|
| 104 |
+
messages = [
|
| 105 |
+
{"role": "user", "content": user_question },
|
| 106 |
+
]
|
| 107 |
+
|
| 108 |
# Example usage
|
| 109 |
+
response = pipe(messages, max_new_tokens=128)
|
| 110 |
+
assistant_response = outputs[0]["generated_text"]
|
|
|
|
| 111 |
|
| 112 |
+
print(f"Question: {user_question}")
|
| 113 |
+
print(f"Answer: {assistant_response}")
|
| 114 |
```
|
| 115 |
|
| 116 |
## Performance
|