bilingual-low-altitude-procurement-safety-retriever
A bilingual (Chinese/English) dense retrieval model over public procurement documents, built by PINNACLE ROBOTICS (Hong Kong).
Version v0.2.0. It supersedes v0.1.0. The scope is still deliberately narrow and honestly labelled.
1. What it is
- Base encoder:
intfloat/multilingual-e5-baseat revisiond128750597153bb5987e10b1c3493a34e5a4502a(MIT, XLM-R, 768-d, mean pooling). - What changed from v0.1.0: v0.1.0 kept the encoder frozen and trained one linear head. v0.2.0 is a full fine-tune of the encoder (all transformer layers; the word-embedding table is frozen and byte-identical to the base). There is no head. The pipeline is
Transformer → mean Pooling → Normalize, and this repository bundles the fine-tuned weights. - Training device: one Ascend 910 NPU (see §7).
- Task: candidate retrieval. Given a short bilingual query, it ranks public tender subject lines and specification clauses.
2. How to use
Queries take the e5 "query: " prefix; passages take no prefix (this matches training). Use the shipped wrapper, which applies this correctly and rejects empty input:
from sentence_transformers import SentenceTransformer
from inference import encode_queries, encode_passages, retrieve
model = SentenceTransformer("pinnacle-robotics/bilingual-low-altitude-procurement-safety-retriever", revision="v0.2.1")
q = encode_queries(model, ["Procurement of an unmanned aerial vehicle system."])
p = encode_passages(model, ["供應及安裝一台升降機,包括保養服務。"])
config_sentence_transformers.json also declares the prompts (query = "query: ", passage = empty), so model.encode(texts, prompt_name="query") is equivalent. Max sequence length: 256 tokens, the training passage length.
3. Intended use and out of scope
- Intended: first-stage ranking for search or RAG over public procurement and regulatory text, with queries in Chinese or English over a mostly-Chinese pool.
- Not a safety-certification, airworthiness, flight-approval or compliance-judgment tool.
- Not trained on aviation regulatory text. The low-altitude coverage gate failed in v0.1 and nothing in v0.2 changes that, so this remains a general bilingual procurement retriever.
- No claim of being first, best, validated, or endorsed by any institution.
4. Data
The pairs, pool and family-grouped splits are identical to v0.1.0 (31,158 pairs; 55,502-passage pool; train/dev/test 25,008 / 3,082 / 3,068; seed 20261019; measured family leakage 0). All text is public tender material. Full description: training/dataset_card.md and training/pairs_summary.json.
Important for reading the numbers below: 29,452 of the 31,158 pairs are cross-lingual pairs whose two sides are translations of unrecorded provenance (pair_origin=machine_translated). Only 1,706 are same_record pairs (a clause with its own supplier question, in the same language). Nothing is human-labelled.
5. Training recipe
In-batch-negative contrastive loss with known-positive and duplicate-positive masking. Temperature 0.05, lr 2e-5 (AdamW, 10% warm-up, linear decay), 3 epochs, batch 64, fp16 AMP. Query length 96 and passage length 256, both pre-tokenised to fixed shapes. The best checkpoint was chosen by dev recall@10 (epoch 2), and the test split was scored once, on that checkpoint. The plain-PyTorch XLM-R port used on the NPU (training/code/xlmr_lite.py) was gated against HF XLMRobertaModel before training (min cosine 0.9999998, n=256).
6. Evaluation
Plain cosine over the full 55,502-passage pool (no ANN). Splits are family-grouped and were locked before scoring.
| system | split | R@5 | R@10 | MRR@10 | n |
|---|---|---|---|---|---|
| frozen e5 (zero-shot) | dev | 0.1080 | 0.1648 | 0.0552 | 3082 |
| v0.1.0 (frozen + linear head) | dev | 0.9169 | 0.9468 | 0.6408 | 3082 |
| v0.2.0 | dev | 0.9555 | 0.9646 | 0.8916 | 3082 |
| v0.1.0 | test | 0.8377 | 0.9081 | — | 3068 |
| v0.2.0 | test | 0.9681 | 0.9798 | 0.9078 | 3068 |
The published SentenceTransformers export scores test R@10 0.9801 / nDCG@10 0.9252 on CPU (Gate C). The 0.0003 difference from the Ascend number is fp16 vs fp32 tie-breaking.
Family-bootstrap 95% CI on R@10 (families are the unit of independence): dev [0.9455, 0.9799], test [0.9702, 0.9878].
Reproduction gate: the dev and test numbers were recomputed off-device (DGX GPU, fp32) from the published checkpoint, and both match the Ascend fp16 run exactly (|Δ| = 0.0000).
Per-slice R@10 — read this before quoting the headline
| slice | dev n | dev R@10 | test n | test R@10 | v0.1.0 dev |
|---|---|---|---|---|---|
| machine_translated (cross-lingual) | 2948 | 0.9817 | 2949 | 0.9871 | 0.9664 |
| same_record | 134 | 0.5896 | 119 | 0.7983 | 0.5149 |
| zh→en | 1471 | 0.9857 | 1474 | 0.9871 | 0.9653 |
| en→zh | 1471 | 0.9816 | 1474 | 0.9871 | 0.9714 |
| zh→zh | 140 (small sample) | 0.5643 | 120 (small sample) | 0.8000 | 0.4929 |
| en→en | 0 | not scored | 0 | not scored | — |
The headline is carried by the cross-lingual translation pairs. The same-language, same-record slice is the realistic one and it is much weaker (dev 0.59, test 0.80). It did improve over v0.1.0 (dev 0.51 → 0.59), but it is small-sample. One dev family (TDR-A21212) contributes 20 of the 140 dev zh→zh queries, and all 20 are the same generic sentence (「请确认是否满足,并提供说明及证明。」, "please confirm compliance and provide explanation and proof") pointing at different clauses. They are unanswerable by construction and score 0. Excluding that family, dev zh→zh is 0.658. The locked evaluation keeps the family in; this note is for the reader.
Memorisation check
R@10 on a seeded 3,000-pair train sample is 0.9893, against dev 0.9646, a gap of 0.025. The frozen model shows the same gap (0.024), so the gap reflects the train sample being slightly easier, not the fine-tune memorising it.
Gate C — CPU round trip (release-blocking)
Run on CPU with standard SentenceTransformers (HF_HUB_OFFLINE=1, empty HF cache). The reference is the training code path (plain-torch encoder + checkpoint, fp32). Criteria are the same as v0.1.0 and were not loosened. Verdict: 11/12 pass. The single failure is the inherited base-tokenizer property described in §8, exactly as in v0.1.0; the shipped tokenizer files are byte-identical to the base.
| check | result |
|---|---|
| fixtures (200 pool passages + 100 test queries + 8 edge cases) | 308 |
| min cosine vs reference | 0.9999997 (≥ 0.999 required) |
| max coordinate diff | 1.2e-06 (≤ 1e-3) |
| norms within 1e-5 of 1 | yes (max dev 2.4e-07) |
| second reload max diff | 0.0 |
| empty / whitespace input | rejected by inference.py |
| test R@10, shipped vs reference (full 55,502 pool) | 0.9801 vs 0.9801 (Δ 0.0000) |
| test nDCG@10, shipped vs reference | 0.9252 vs 0.9252 (Δ 0.00004) |
| top-10 overlap, shipped vs reference | 0.9993 |
| tokenizer round trip | fails on U+FF0C → , (base property; files identical to base) |
Full output: evaluation/cpu_roundtrip.json.
7. Compute
- Training: Ascend 910 (
Ascend910ProA, 1 card), fp16 AMP, ModelArts training job09deb869-e137-430b-8e71-4a07e6045d7c, which completed in 1,740 s of in-job time. The job record attestsdevice_used: npu:0(evaluation/ascend_job_record.json,evaluation/ascend_npu_smi.txt). - NPU-hours used by this release: ≈0.5 (1 × 910 for ~29 minutes).
- Pre-tokenisation, the reproduction check and Gate C ran on a DGX Spark (aarch64). Gate C ran on its CPU.
8. Limitations
- Weak labels only. The cross-lingual pairs are translation pairs, an easier task than open retrieval, and they dominate the headline. Quote the same_record slice alongside it.
- EN→EN retrieval is not covered by this corpus.
- The corpus spans 7 tender markets and is EU-heavy by row count.
- Cross-script pairs (Simplified ↔ Traditional) are present; expect script sensitivity.
- Inputs longer than 256 tokens are truncated (0.14% of pool passages).
- Base-tokenizer property, inherited from multilingual-e5-base: decode maps the full-width comma U+FF0C to ASCII
,. This affects decode only, not the embeddings, and the shipped tokenizer files are byte-identical to the base.
9. Attribution
Built by PINNACLE ROBOTICS (Hong Kong).
10. Versioning
- v0.1.0: frozen e5 plus one linear head, trained on CPU.
- v0.2.0: full encoder fine-tune on Ascend 910, with large gains on cross-lingual retrieval and a modest gain on same-record retrieval.
- Next: a cross-encoder reranker over v0.2 top-50 hard negatives, an independently reviewed same-language relevance set, and English passage text so EN→EN is covered.
License
MIT, the base model's license. The base encoder is intfloat/multilingual-e5-base at revision d128750597153bb5987e10b1c3493a34e5a4502a; see NOTICE.