File size: 4,631 Bytes
8d29357
 
 
 
 
 
 
3206b1f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4771944
3206b1f
 
 
 
0dc9d6a
 
3206b1f
0dc9d6a
3206b1f
 
0dc9d6a
 
3206b1f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0dc9d6a
 
3206b1f
 
 
0dc9d6a
caa8848
 
0dc9d6a
 
 
 
 
caa8848
0dc9d6a
caa8848
0dc9d6a
caa8848
0dc9d6a
caa8848
 
3206b1f
 
 
 
 
 
 
 
 
7a3ca27
4771944
3206b1f
 
 
 
 
4771944
3206b1f
 
 
 
 
 
 
4771944
3206b1f
 
 
 
 
 
 
 
 
4771944
3206b1f
 
 
 
 
 
 
 
 
caa8848
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
---
license: apache-2.0
tags:
- unsloth
- trl
- grpo
---
# ALLaM-Thinking: Arabic Large Language Model with Enhanced Reasoning Capabilities

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Hugging Face](https://img.shields.io/badge/๐Ÿค—%20Hugging%20Face-almaghrabima/ALLaM--Thinking-yellow)](https://huggingface.co/almaghrabima/ALLaM-Thinking)
[![Unsloth Optimized](https://img.shields.io/badge/Optimized%20with-Unsloth-green)](https://github.com/unslothai/unsloth)

## Overview

ALLaM-Thinking is an advanced Arabic Large Language Model specifically optimized for reasoning and mathematical problem-solving tasks. This model builds on state-of-the-art language model architecture and has been fine-tuned using the Unsloth library for improved performance and efficiency.

## Key Features

- **Arabic-First Design**: Built from the ground up to excel at understanding and generating high-quality Arabic text
- **Enhanced Reasoning**: Specialized in step-by-step problem solving, particularly for mathematical questions
- **Optimized Performance**: Accelerated using Unsloth for faster inference and reduced computational requirements
- **GRPO Implementation**: Utilizes Group Relative Policy Optimization for improved alignment

## Usage Example

```python
from transformers import AutoTokenizer
from vllm import LLM, SamplingParams

# Load the tokenizer
tokenizer = AutoTokenizer.from_pretrained("almaghrabima/ALLaM-Thinking")

# Initialize the model using vLLM
# Note: You should only initialize the model once, using vLLM directly
model = LLM(model="almaghrabima/ALLaM-Thinking")

# Format the prompt using chat template
text = tokenizer.apply_chat_template([
    {"role": "user", "content": "ููŠ ูุฑูŠู‚ ู…ูƒูˆู† ู…ู† 15 ู„ุงุนุจุงู‹ุŒ 40% ู…ู†ู‡ู… ูŠุณุฌู„ูˆู† ุงู„ุฃู‡ุฏุงู. ุฅุฐุง ุณุฌู„ ูƒู„ ู„ุงุนุจ ู…ู† ุงู„ู„ุงุนุจูŠู† ุงู„ุฐูŠู† ูŠุณุฌู„ูˆู† ุงู„ุฃู‡ุฏุงู ููŠ ุงู„ู…ุชูˆุณุท 5 ุฃู‡ุฏุงู ุฎู„ุงู„ ุงู„ู…ูˆุณู…ุŒ ููƒู… ุนุฏุฏ ุงู„ุฃู‡ุฏุงู ุงู„ูƒู„ูŠ ุงู„ุชูŠ ุณุฌู„ู‡ุง ุงู„ู„ุงุนุจูˆู† ุงู„ุฐูŠู† ูŠุณุฌู„ูˆู† ุงู„ุฃู‡ุฏุงูุŸ"}
], tokenize=False, add_generation_prompt=True)

# Configure sampling parameters
sampling_params = SamplingParams(
    temperature=0.8,
    top_p=0.95,
    max_tokens=1024,
)

# Generate response
outputs = model.generate([text], sampling_params)
output = outputs[0].outputs[0].text
print(output)
```

## Answer

```
 ุฃูˆู„ุงู‹ุŒ ุฏุนู†ุง ู†ุฌุฏ ุนุฏุฏ ุงู„ู„ุงุนุจูŠู† ุงู„ุฐูŠู† ูŠุณุฌู„ูˆู† ุงู„ุฃู‡ุฏุงู.

40% ู…ู† 15 ู„ุงุนุจุงู‹ ูŠุณุงูˆูŠ:

0.40 * 15 = 6 ู„ุงุนุจูŠู†

ุงู„ุขู†ุŒ ุฅุฐุง ูƒุงู† ูƒู„ ู„ุงุนุจ ู…ู† ู‡ุคู„ุงุก ุงู„ู„ุงุนุจูŠู† ุงู„ุณุชุฉ ูŠุณุฌู„ ููŠ ุงู„ู…ุชูˆุณุท 5 ุฃู‡ุฏุงู ุฎู„ุงู„ ุงู„ู…ูˆุณู…ุŒ ูุฅู† ุฅุฌู…ุงู„ูŠ ุนุฏุฏ ุงู„ุฃู‡ุฏุงู ุงู„ุชูŠ ุณุฌู„ู‡ุง ุงู„ู„ุงุนุจูˆู† ุงู„ุฐูŠู† ูŠุณุฌู„ูˆู† ุงู„ุฃู‡ุฏุงู ุณูŠูƒูˆู†:

6 ู„ุงุนุจูŠู† * 5 ุฃู‡ุฏุงู ู„ูƒู„ ู„ุงุนุจ = 30 ู‡ุฏูุงู‹

ู„ุฐู„ูƒุŒ ุณุฌู„ ุงู„ู„ุงุนุจูˆู† ุงู„ุฐูŠู† ูŠุณุฌู„ูˆู† ุงู„ุฃู‡ุฏุงู ู…ุฌู…ูˆุน 30 ู‡ุฏูุงู‹ ุฎู„ุงู„ ุงู„ู…ูˆุณู…. 
```

## Unsloth Optimization

This model has been optimized using [Unsloth](https://github.com/unslothai/unsloth), which provides significant speedups for training and inference.

## Training Details

ALLaM-Thinking was trained using a combination of techniques:

- Base architecture fine-tuned on diverse Arabic datasets
- GRPO (Group Relative Policy Optimization) for better alignment
- Specialized training on mathematical reasoning and step-by-step problem-solving

## Performance

ALLaM-Thinking demonstrates strong capabilities in:

- Mathematical problem-solving with step-by-step reasoning
- Logical analysis and deduction
- Maintaining coherence in long-form responses
- Domain-specific reasoning in technical fields

## Limitations

- Model outputs should always be verified by human experts, especially for critical applications
- May occasionally produce incorrect mathematical reasoning despite the step-by-step approach
- Limited context window compared to some larger models
- Performance may vary based on query complexity and domain specificity

## Citation

If you use ALLaM-Thinking in your research or applications, please cite:

```bibtex
@misc{almaghrabima2025allam,
  author = {Mohammed Al-Maghrabi Research},
  title = {ALLaM-Thinking: Arabic Large Language Model with Enhanced Reasoning Capabilities},
  year = {2025},
  publisher = {Hugging Face},
  howpublished = {\url{https://huggingface.co/almaghrabima/ALLaM-Thinking}}
}
```

## License

This model is released under the [Apache 2.0 License](https://opensource.org/licenses/Apache-2.0).