Text Generation
Transformers
Safetensors
Italian
English
quark
causal-lm
bilingual
italian
english
small-language-model
trained-from-scratch
conversational
custom_code
Instructions to use ThingAI/ARK-135M-Bilingual with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ThingAI/ARK-135M-Bilingual with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ThingAI/ARK-135M-Bilingual", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("ThingAI/ARK-135M-Bilingual", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ThingAI/ARK-135M-Bilingual with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ThingAI/ARK-135M-Bilingual" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ThingAI/ARK-135M-Bilingual", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ThingAI/ARK-135M-Bilingual
- SGLang
How to use ThingAI/ARK-135M-Bilingual with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "ThingAI/ARK-135M-Bilingual" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ThingAI/ARK-135M-Bilingual", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "ThingAI/ARK-135M-Bilingual" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ThingAI/ARK-135M-Bilingual", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ThingAI/ARK-135M-Bilingual with Docker Model Runner:
docker model run hf.co/ThingAI/ARK-135M-Bilingual
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,179 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- it
|
| 4 |
+
- en
|
| 5 |
license: apache-2.0
|
| 6 |
+
tags:
|
| 7 |
+
- text-generation
|
| 8 |
+
- causal-lm
|
| 9 |
+
- bilingual
|
| 10 |
+
- italian
|
| 11 |
+
- english
|
| 12 |
+
- small-language-model
|
| 13 |
+
- trained-from-scratch
|
| 14 |
+
- quark
|
| 15 |
+
library_name: transformers
|
| 16 |
+
pipeline_tag: text-generation
|
| 17 |
+
model-index:
|
| 18 |
+
- name: Quark-135m-v0.2
|
| 19 |
+
results: []
|
| 20 |
---
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
## Overview
|
| 24 |
+
|
| 25 |
+
Quark-135m v0.2 is a compact bilingual language model designed for Italian and English, built entirely from scratch by [ThingsAI](https://things-ai.org). It represents the second generation of the Quark model family, featuring a custom bilingual BPE tokenizer and a modern transformer architecture.
|
| 26 |
+
|
| 27 |
+
This is the **base pretrained model**. An SFT (instruction-tuned) version trained on bilingual conversational data is available for chat applications.
|
| 28 |
+
|
| 29 |
+
## Model Details
|
| 30 |
+
|
| 31 |
+
| | |
|
| 32 |
+
|---|---|
|
| 33 |
+
| **Parameters** | 135M (143.98M with embeddings) |
|
| 34 |
+
| **Architecture** | Decoder-only Transformer |
|
| 35 |
+
| **Vocabulary** | 65,536 tokens (custom bilingual BPE) |
|
| 36 |
+
| **Context Length** | 2,048 tokens |
|
| 37 |
+
| **Precision** | BF16 |
|
| 38 |
+
| **Languages** | Italian, English |
|
| 39 |
+
| **Tokenizer** | [ThingAI/QuarkTokenizer](https://huggingface.co/ThingAI/QuarkTokenizer) |
|
| 40 |
+
| **License** | Apache 2.0 |
|
| 41 |
+
|
| 42 |
+
## Architecture
|
| 43 |
+
|
| 44 |
+
Quark-135m follows a SmolLM-inspired design optimized for efficiency at small scale:
|
| 45 |
+
|
| 46 |
+
| Component | Details |
|
| 47 |
+
|---|---|
|
| 48 |
+
| Attention | Grouped Query Attention (GQA) |
|
| 49 |
+
| Heads | 9 query heads, 3 KV heads |
|
| 50 |
+
| Head Dimension | 64 |
|
| 51 |
+
| Model Dimension | 576 |
|
| 52 |
+
| Layers | 30 |
|
| 53 |
+
| FFN Dimension | 1,536 |
|
| 54 |
+
| FFN Activation | SwiGLU |
|
| 55 |
+
| Normalization | RMSNorm (pre-attention & pre-FFN) |
|
| 56 |
+
| Positional Encoding | Rotary Position Embeddings (RoPE) |
|
| 57 |
+
| Weight Tying | Yes (embedding โ LM head) |
|
| 58 |
+
|
| 59 |
+
## Training
|
| 60 |
+
|
| 61 |
+
### Pretraining Data
|
| 62 |
+
|
| 63 |
+
Quark-135m v0.2 was pretrained on **15.7B tokens** from a curated bilingual mix:
|
| 64 |
+
|
| 65 |
+
| Subset | Weight | Source |
|
| 66 |
+
|---|---|---|
|
| 67 |
+
| FineWeb-2 (Italian) | 29% | `HuggingFaceFW/fineweb-2` [ita_Latn] |
|
| 68 |
+
| CulturaX (Italian) | 14% | `uonlp/CulturaX` [it] |
|
| 69 |
+
| Wikipedia (Italian) | 7% | `wikimedia/wikipedia` [20231101.it] |
|
| 70 |
+
| FineWeb (English) | 36% | `HuggingFaceFW/fineweb` [sample-10BT] |
|
| 71 |
+
| Wikipedia (English) | 7% | `wikimedia/wikipedia` [20231101.en] |
|
| 72 |
+
| The Stack (Code) | 7% | `bigcode/the-stack-smol` |
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
## Chat Format
|
| 77 |
+
|
| 78 |
+
The model uses a simple chat template:
|
| 79 |
+
|
| 80 |
+
```
|
| 81 |
+
<|user|>
|
| 82 |
+
{user message}
|
| 83 |
+
<|end|>
|
| 84 |
+
<|assistant|>
|
| 85 |
+
{model response}
|
| 86 |
+
<|end|>
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
## Tokenizer
|
| 90 |
+
|
| 91 |
+
Quark-135m v0.2 uses a custom bilingual BPE tokenizer ([ThingAI/QuarkTokenizer](https://huggingface.co/ThingAI/QuarkTokenizer)) specifically designed for Italian and English:
|
| 92 |
+
|
| 93 |
+
- **Vocabulary**: 65,536 tokens
|
| 94 |
+
- **Type**: Byte-Pair Encoding (BPE)
|
| 95 |
+
- **Languages**: Balanced Italian + English coverage
|
| 96 |
+
- **Published**: [ThingAI/QuarkTokenizer](https://huggingface.co/ThingAI/QuarkTokenizer)
|
| 97 |
+
|
| 98 |
+
## Usage
|
| 99 |
+
|
| 100 |
+
### Loading the Model
|
| 101 |
+
|
| 102 |
+
Quark uses a custom architecture. To load and run inference:
|
| 103 |
+
|
| 104 |
+
```python
|
| 105 |
+
import torch
|
| 106 |
+
import json
|
| 107 |
+
from safetensors.torch import load_file
|
| 108 |
+
from transformers import AutoTokenizer
|
| 109 |
+
|
| 110 |
+
# Load tokenizer
|
| 111 |
+
tokenizer = AutoTokenizer.from_pretrained("ThingAI/Quark-135m-v0.2")
|
| 112 |
+
|
| 113 |
+
# Load model (requires custom architecture classes โ see repository)
|
| 114 |
+
# Full architecture code available in the model repository
|
| 115 |
+
```
|
| 116 |
+
|
| 117 |
+
### Generation Example
|
| 118 |
+
|
| 119 |
+
```python
|
| 120 |
+
prompt = "<|user|>\nCos'รจ l'intelligenza artificiale?\n<|end|>\n<|assistant|>\n"
|
| 121 |
+
ids = tokenizer.encode(prompt, return_tensors="pt").to("cuda")
|
| 122 |
+
|
| 123 |
+
# Token-by-token generation with sampling
|
| 124 |
+
with torch.no_grad():
|
| 125 |
+
for _ in range(200):
|
| 126 |
+
logits = model(ids)[:, -1, :] / 0.7 # temperature
|
| 127 |
+
topk = torch.topk(logits, 40)
|
| 128 |
+
probs = torch.softmax(topk.values, -1)
|
| 129 |
+
idx = topk.indices.gather(-1, torch.multinomial(probs, 1))
|
| 130 |
+
ids = torch.cat([ids, idx], -1)
|
| 131 |
+
if idx.item() == tokenizer.eos_token_id:
|
| 132 |
+
break
|
| 133 |
+
|
| 134 |
+
print(tokenizer.decode(ids[0], skip_special_tokens=False))
|
| 135 |
+
```
|
| 136 |
+
|
| 137 |
+
## Limitations
|
| 138 |
+
|
| 139 |
+
- **Scale**: At 135M parameters, the model has limited factual knowledge and reasoning capacity
|
| 140 |
+
- **Hallucination**: The model frequently generates plausible but incorrect information
|
| 141 |
+
- **Mathematics**: Cannot reliably perform arithmetic beyond simple operations
|
| 142 |
+
- **Code**: Generates syntactically plausible but often non-functional code
|
| 143 |
+
- **Vocabulary overhead**: The 65k vocabulary consumes ~26% of model parameters in the embedding layer, reducing transformer capacity โ a key lesson for v0.3
|
| 144 |
+
- **Pretraining plateau**: Loss plateaued at ~4.6 due to the vocab/parameter ratio imbalance
|
| 145 |
+
|
| 146 |
+
## Comparison with v0.1
|
| 147 |
+
|
| 148 |
+
| | Quark-135m v0.1 | Quark-135m v0.2 |
|
| 149 |
+
|---|---|---|
|
| 150 |
+
| **Tokenizer** | cosmo2 (49k) | QuarkTokenizer (65k) |
|
| 151 |
+
| **Languages** | Math-focused (EN) | Bilingual IT+EN |
|
| 152 |
+
| **Training Data** | 15B tokens (math-heavy) | 15.7B tokens (bilingual web + code) |
|
| 153 |
+
| **Final Loss** | ~3.5-4.0 | 4.635 |
|
| 154 |
+
| **Strengths** | Arithmetic, math reasoning | Italian fluency, bilingual chat |
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
## Citation
|
| 159 |
+
|
| 160 |
+
```bibtex
|
| 161 |
+
@misc{quark2026,
|
| 162 |
+
title={Quark: A Family of Compact Bilingual Language Models},
|
| 163 |
+
author={Di Nicola, Michelangelo},
|
| 164 |
+
year={2026},
|
| 165 |
+
publisher={ThingsAI},
|
| 166 |
+
url={https://huggingface.co/ThingAI/Quark-135m-v0.2}
|
| 167 |
+
}
|
| 168 |
+
```
|
| 169 |
+
|
| 170 |
+
## Links
|
| 171 |
+
|
| 172 |
+
- ๐ [ThingsAI Website](https://things-ai.org)
|
| 173 |
+
- ๐ฌ [Things Chat](https://chat.things-ai.org)
|
| 174 |
+
- ๐ค [QuarkTokenizer](https://huggingface.co/ThingAI/QuarkTokenizer)
|
| 175 |
+
- ๐ [Open SLM Leaderboard](https://huggingface.co/spaces/AxiomicLabs/Open_SLM_Leaderboard)
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
*Built from scratch by ThingsAI ๐ฎ๐น*
|