File size: 12,050 Bytes
5304d2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52d29d0
5304d2b
 
 
 
52d29d0
5304d2b
 
52d29d0
5304d2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17d62da
 
52d29d0
 
 
5304d2b
52d29d0
5304d2b
52d29d0
 
 
 
 
 
 
5304d2b
 
 
52d29d0
 
 
5304d2b
 
 
 
 
 
 
 
 
 
7738bac
 
 
5304d2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17d62da
5304d2b
 
 
52d29d0
 
 
5304d2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52d29d0
 
 
5304d2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
---
license: apache-2.0
base_model: Qwen/Qwen3.5-0.8B
base_model_relation: adapter
pipeline_tag: text-generation
language:
- it
- en
tags:
- query-translation
- translation
- cross-lingual-retrieval
- retrieval
- hybrid-search
- bm25
- rag
- distillation
- lora
- slm
- gguf
- multilingual
- qwen3.5
model-index:
- name: QueryTranslator-0.8B
  results:
  - task:
      type: text-retrieval
      name: 'Library search across languages: the document a question was written from, searched with the question translated for the word index'
    dataset:
      type: gramscii-library-questions
      name: 200 questions, 100 English on Italian documents and 100 Italian on English documents
      split: test
    metrics:
    - type: recall_at_20
      name: Documents found among the 20 passages kept (%)
      value: 19.0
    - type: mrr
      name: Mean reciprocal rank of the document
      value: 0.103
  - task:
      type: text-retrieval
      name: 'Open Data search across languages: the dataset that answers a request, among the ones offered'
    dataset:
      type: gramscii-opendata-requests
      name: 31 requests whose answering datasets are described in another language, answers reviewed on 7 November
      split: test
    metrics:
    - type: recall
      name: Answering dataset offered (%)
      value: 25.8
    - type: mrr
      name: Mean reciprocal rank of the answering dataset
      value: 0.142
  - task:
      type: translation
      name: 'A search request written again in the language of the passages it is looked up in'
    dataset:
      type: gramscii-query-translations
      name: 382 held-out search requests (223 into Italian, 159 into English), translated by the teacher
      split: test
    metrics:
    - type: exact_match
      name: The teacher's translation, Qwen3.8-27B, word for word (%)
      value: 33.2
    - type: accuracy
      name: 'Well formed: one line, every number and code kept, not the request copied (%)'
      value: 100.0
    - type: f1
      name: Words shared with the teacher's translation, mean F1 (%)
      value: 90.9
---

# QueryTranslator-0.8B

A LoRA adapter on Qwen3.5-0.8B that writes a search request again in the
language of the passages it will be looked up in, between **Italian and
English**, so that a word index written in that language finds them.

It is made for hybrid search over documents in more than one language. The
meaning search (embeddings) and the reranker keep the person's own words: they
read every language. Words match only within one language, so each language
the passages are written in gets a word index of its own, and the request is
written again in that language for it. Only the word search reads the
translation: a wrong one can add candidates and never remove one.

It is a distillation: it learned the translations of a teacher 34 times its
size, Qwen3.8-27B, and the measure that matters is what the search then
finds. With it, the search finds as many documents written in another
language as with a 4-billion, a 35-billion or a 284-billion-parameter model
doing the same job, as many datasets as the 4-billion model we fine-tuned
and the 284-billion one, and writes each request faster: 0.16 seconds against
0.23 to 0.85.

| translator | library documents found across languages, of 200 | mean reciprocal rank | Open Data datasets found across languages, of 31 | mean reciprocal rank | seconds a request |
|---|---|---|---|---|---|
| no translation, the person's own words | 23 | 0.056 | 7 | 0.145 | — |
| **QueryTranslator-0.8B** | **38** | **0.103** | **8** | **0.142** | **0.16** |
| Qwen3.5-4B fine-tuned by Gramscii | 37 | 0.096 | 8 | 0.137 | 0.23 |
| Qwen3.5-4B, thinking off | 36 | 0.100 | — | — | 0.33 |
| Qwen3.6-35B-A3B, thinking off (MoE, 3B active) | 37 | 0.100 | — | — | 0.41 |
| DeepSeek-V4-Flash | 37 | 0.102 | 8 | 0.137 | 0.85 |
| Qwen3.5-0.8B, no adapter | 25 | 0.067 | — | — | 0.11 |

Each translator was asked with the sampling its own card gives (ours greedy),
and timed on one NVIDIA A100 64 GB with llama.cpp, one request at a time, the
median of 50 requests; DeepSeek-V4-Flash on three, which it needs. The Open
Data search was measured again on 8 November, with the answers reviewed on 7
November, for the translators still served then; a dash marks the others. The searches are described under *What it is measured
to do*.

## What is in this repository

| file | what it is |
|---|---|
| `qwen3.5-0.8b-base-2fc06364-q8_0.gguf` | **the base**: Qwen3.5-0.8B at revision `2fc06364`, Q8_0, 833,592,320 bytes, sha256 `6a94a8273ab1fc5735743967b621eb5a3baba8e36a202f61c20dc47fbb80eb51` |
| `query-translator-0.8b-20261107-lora-f16.gguf` | **the adapter** of 7 November 2026, F16 LoRA, 21,671,008 bytes, sha256 `2cd2981ab2673b84ea36ad0ee2d033e28838c449a571ae5c891d6276c0acc9ee` |
| `LICENSE` | the base model's Apache-2.0 licence |

The base is the same file other Gramscii adapters load,
[SemanticRepair-0.8B](https://huggingface.co/Gramscii-IT/SemanticRepair-0.8B) and
[ToolChooser-0.8B](https://huggingface.co/Gramscii-IT/ToolChooser-0.8B):
one base serves every job, and each adapter costs 21.7 MB, not another 800 MB
model. Pin the sha256 of both files: a search has to be reproducible.

## Where it runs

With llama-server:

```
llama-server -m qwen3.5-0.8b-base-2fc06364-q8_0.gguf \
  --lora query-translator-0.8b-20261107-lora-f16.gguf \
  --jinja --host 127.0.0.1 --port 9250 -ngl 99 -c 8192 --no-context-shift --cache-ram 0
```

When the base also carries other adapters, each request names this one at
full scale and the others at none, as `"lora": [{"id": 0, "scale": 1.0}, ...]`.

## What it reads and writes

It reads the base model's chat template (llama-server `--jinja`, thinking
off), with the system and user messages it was trained on, `{output_language}`
and `{source_language}` being the English names of the languages (`Italian`,
`English`) and `{question}` the request as the person wrote it:

```
# System
You write a reader's search request again in {output_language}, so that it can be looked up in passages written in {output_language}. You only write the request again: you never answer it.

- Keep its whole meaning: every subject, measure, place, period and name it gives.
- Keep names, codes, acronyms and numbers exactly as the reader wrote them.
- Use the words that passages in {output_language} use for the same things.

Answer with the request in {output_language}, on one line, and nothing else.

# User
The request, in {source_language}:

{question}
```

This is the whole call, on `/v1/chat/completions`:

```json
{
  "messages": [{"role": "system", "content": "..."}, {"role": "user", "content": "..."}],
  "temperature": 0.0,
  "top_k": 1,
  "max_tokens": 128,
  "chat_template_kwargs": {"enable_thinking": false}
}
```

Greedy, because one request is always written the same way, so each is asked
once. The first non-empty line of the answer is the request.

## What it is measured to do

**Searching across languages.** The same search with each translator in its
place, nothing else changed: the embedding model, the reranker, the word
indexes and the documents searched, the same for all, unchanged for the whole
measure.

- *Library*: 100 questions in each direction, each written by the teacher
  from one document, searched over the whole library of the chat it was asked
  in (about 343,000 passages for an Italian question, 41,000 for an English
  one, documents in both languages) with no document selected, so few are
  found at all: a person usually searches the files they chose. Found means
  a passage of that document among the 20 kept; the rank is that of its
  first passage.

  | | English questions, Italian documents: found / first / in the first 5 | Italian questions, English documents: found / first / in the first 5 |
  |---|---|---|
  | no translation | 21 / 6 / 17 | 2 / 0 / 0 |
  | **QueryTranslator-0.8B** | **29 / 11 / 23** | 9 / 2 / 7 |
  | Qwen3.5-4B fine-tuned by Gramscii | 27 / 10 / 22 | 10 / 1 / 8 |
  | Qwen3.5-4B, thinking off | 26 / 10 / 22 | 10 / 2 / 8 |
  | Qwen3.6-35B-A3B, thinking off | 28 / 10 / 22 | 9 / 3 / 7 |
  | DeepSeek-V4-Flash | 28 / 11 / 23 | 9 / 2 / 7 |
  | Qwen3.5-0.8B, no adapter | 23 / 8 / 20 | 2 / 0 / 0 |

- *Open Data*: the datasets offered for 20 requests written before any of
  this was measured and 60 held out of every training, 80 in all, their
  answers reviewed on 7 November; 31 of them are answered only by datasets
  described in another language than the request's. Found means an answering dataset among the ones offered.

**The teacher's translations.** 382 held-out search requests, 223 written
into Italian and 159 into English, each with the translation the teacher,
Qwen3.8-27B, wrote when the application asked it:

| | the teacher's translation, word for word | well formed | words shared with the teacher's, mean |
|---|---|---|---|
| Qwen3.8-27B, asked again | 342 | 382 | 99% |
| **QueryTranslator-0.8B** | **127** | **382** | **91%** |
| Qwen3.5-4B fine-tuned by Gramscii | 74 | 381 | 86% |
| Qwen3.6-35B-A3B, thinking off | 63 | 382 | 85% |
| Qwen3.5-4B, thinking off | 54 | 382 | 83% |
| LFM2.5-24B-A2B, thinking on (it cannot be turned off) | 49 | 382 | 83% |
| Qwen3.5-0.8B, no adapter | 0 | 232 | 38% |

Well formed means one line, every number and code of the request kept, and
not the request copied. The teacher asked again gives its own translation 342
times of 382: about as close as anyone imitating it can come. LFM2.5 takes
3.7 seconds a request on the same A100, since it always reasons first.

## What it does not fix

**Within one language, the translated word leg costs a little.** The
passages it adds in the other language compete with the right ones: Open Data
requests answered in their own language rank their dataset first 7 times of
49 with QueryTranslator or DeepSeek-V4-Flash and 6 with the 4B model we
fine-tuned, against 12 with no translation, and the
library loses one to four documents in a hundred. This is the search's design,
not the translation: weigh the translated leg as your corpus asks.

**Where it differs from the teacher, it is mostly in the words chosen.**
«funding» for «financing», «bando» for «call», another order; now and then a
rare term goes wrong, as «collateral» once did.

**Measured from Italian into English and from English into Italian.** Its
training rows hold a few hundred translations into French, German and
Spanish; no measure covers them.

## The data it was trained on

**38,514 training rows and 382 validation rows**: the translations the
teacher, Qwen3.8-27B, wrote when the application's searches asked for them in
scripted conversations played through it, 22,417 into Italian, 15,868 into
English and 229 into French, German and Spanish. 34,859 of the rows kept were
collected on the Leonardo supercomputer (12 runs at once, 34 hours, 6.0
million tokens), 4,037 from Qwen3.8-27B served by Regolo (39 hours, 0.7
million tokens). A row is kept only when the answer is one line, not the
request copied, and keeps every number and code of the request; one answer
for each request and language, the first recorded; no request any measure
above uses. One request in a hundred, drawn by its digest, is held out for
validation.

## Training

| | |
|---|---|
| base | [`Qwen/Qwen3.5-0.8B`](https://huggingface.co/Qwen/Qwen3.5-0.8B) at `2fc06364`, its language model only |
| method | LoRA, rank 16, alpha 32, dropout 0.05, on every linear layer but the embeddings and the head (186 modules, 10.8M parameters) |
| schedule | one pass: 4,815 updates of 8 examples, learning rate 1×10⁻⁴, 100 warm-up steps |
| tokens | 6.6M in the examples, 0.9M of them in the answers |
| loss | on the answer only |
| hardware | one NVIDIA A100 64 GB of the Leonardo supercomputer in Bologna, thanks to CINECA |
| release | F16 LoRA GGUF |

## Licence

Apache-2.0, as its base model
[Qwen3.5-0.8B](https://huggingface.co/Qwen/Qwen3.5-0.8B). What it writes is
yours, and so is the responsibility for what you let it search.