eoinedge commited on
Commit
c07ca17
·
verified ·
1 Parent(s): ed9a596

Domain-tuned embeddings with held-out recall@5

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "embedding_dimension": 384,
3
+ "pooling_mode": "mean",
4
+ "include_prompt": true
5
+ }
README.md ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ tags:
6
+ - zephyr
7
+ - sentence-transformers
8
+ - feature-extraction
9
+ - sentence-similarity
10
+ - retrieval
11
+ - rag
12
+ base_model: sentence-transformers/all-MiniLM-L6-v2
13
+ pipeline_tag: sentence-similarity
14
+ library_name: sentence-transformers
15
+ ---
16
+
17
+ # Zephyr RTOS documentation embeddings
18
+
19
+ `all-MiniLM-L6-v2` fine-tuned on the Zephyr RTOS documentation, for retrieval over
20
+ that corpus.
21
+
22
+ - **Comparison Space:** https://huggingface.co/spaces/eoinedge/zephyrproject-embeddings-compare
23
+ - **Index and pipeline:** https://huggingface.co/eoinedge/zephyrproject
24
+ - **Source:** https://github.com/eoinjordan/zephyrproject-rag
25
+
26
+ ## What it is for
27
+
28
+ The base model is trained on general web text, where "binding" means a contract and "west" is a direction. This copy is
29
+ adapted to Zephyr RTOS's vocabulary so those senses separate.
30
+
31
+ Use it as a drop-in replacement for the base model when embedding Zephyr RTOS
32
+ documentation:
33
+
34
+ ```python
35
+ from sentence_transformers import SentenceTransformer
36
+
37
+ model = SentenceTransformer("eoinedge/zephyrproject-docs-embeddings")
38
+ vectors = model.encode(passages, normalize_embeddings=True)
39
+ ```
40
+
41
+ ## Training
42
+
43
+ | | |
44
+ |---|---|
45
+ | Base | `sentence-transformers/all-MiniLM-L6-v2` |
46
+ | Pairs | 6,079 mined from the docs' own heading/body structure |
47
+ | Loss | `MultipleNegativesRankingLoss` (in-batch negatives) |
48
+ | Epochs | 1 |
49
+ | Batch size | 32 |
50
+ | Held-out pairs | 400 |
51
+
52
+ No hand-labelled data and no synthetic questions from a generator — a section
53
+ heading is a natural query for the body beneath it, and it is already written by
54
+ the documentation authors.
55
+
56
+ ## Results, and how to read them
57
+
58
+ | Metric | Base | Tuned |
59
+ |---|---|---|
60
+ | recall@5 on held-out pairs | 0.63 | **0.86** |
61
+
62
+ **That number flatters the model, and you should treat it with suspicion.** The
63
+ evaluation measures the same heading→body relationship the model was trained on,
64
+ so it partly measures whether training converged rather than whether retrieval
65
+ improved.
66
+
67
+ Spot-checking real questions gives a more mixed picture: some clearly improve,
68
+ several are unchanged, and at least one regressed. Real questions are not phrased
69
+ like section headings, which is exactly the gap this evaluation does not cover.
70
+
71
+ The comparison Space runs both models on the same query so you can judge for
72
+ yourself rather than trusting the headline.
73
+
74
+ ## Limitations
75
+
76
+ - One epoch, one seed, no hyperparameter search.
77
+ - Evaluation is aligned with the training objective, as above.
78
+ - Trained on Zephyr RTOS documentation only — it will not help on other corpora and
79
+ may be worse than the base model there.
80
+ - This adapts the **retriever**, not a generator. It does not teach a coding
81
+ model anything about Zephyr RTOS; it changes which passages that model is handed.
82
+
83
+ ## Licence
84
+
85
+ Apache-2.0, matching the base model.
config.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_cross_attention": false,
3
+ "architectures": [
4
+ "BertModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "bos_token_id": null,
8
+ "classifier_dropout": null,
9
+ "dtype": "float32",
10
+ "eos_token_id": null,
11
+ "gradient_checkpointing": false,
12
+ "hidden_act": "gelu",
13
+ "hidden_dropout_prob": 0.1,
14
+ "hidden_size": 384,
15
+ "initializer_range": 0.02,
16
+ "intermediate_size": 1536,
17
+ "is_decoder": false,
18
+ "layer_norm_eps": 1e-12,
19
+ "max_position_embeddings": 512,
20
+ "model_type": "bert",
21
+ "num_attention_heads": 12,
22
+ "num_hidden_layers": 6,
23
+ "pad_token_id": 0,
24
+ "position_embedding_type": "absolute",
25
+ "tie_word_embeddings": true,
26
+ "transformers_version": "5.12.1",
27
+ "type_vocab_size": 2,
28
+ "use_cache": false,
29
+ "vocab_size": 30522
30
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "pytorch": "2.8.0+cpu",
4
+ "sentence_transformers": "5.6.0",
5
+ "transformers": "5.12.1"
6
+ },
7
+ "default_prompt_name": null,
8
+ "model_type": "SentenceTransformer",
9
+ "prompts": {
10
+ "document": "",
11
+ "query": ""
12
+ },
13
+ "similarity_fn_name": "cosine"
14
+ }
eval.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "base_model": "sentence-transformers/all-MiniLM-L6-v2",
3
+ "train_pairs": 6079,
4
+ "eval_pairs": 400,
5
+ "epochs": 1,
6
+ "batch_size": 32,
7
+ "recall_at_5_baseline": 0.63,
8
+ "recall_at_5_tuned": 0.86
9
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:311b52e7d2d55cbb6f2858d0a9feaa761fa92f9e3adc921cc997817e7653f2af
3
+ size 90864192
modules.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": "",
6
+ "type": "sentence_transformers.base.modules.transformer.Transformer"
7
+ },
8
+ {
9
+ "idx": 1,
10
+ "name": "1",
11
+ "path": "1_Pooling",
12
+ "type": "sentence_transformers.sentence_transformer.modules.pooling.Pooling"
13
+ },
14
+ {
15
+ "idx": 2,
16
+ "name": "2",
17
+ "path": "2_Normalize",
18
+ "type": "sentence_transformers.sentence_transformer.modules.normalize.Normalize"
19
+ }
20
+ ]
sentence_bert_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "transformer_task": "feature-extraction",
3
+ "modality_config": {
4
+ "text": {
5
+ "method": "forward",
6
+ "method_output_name": "last_hidden_state"
7
+ }
8
+ },
9
+ "module_output_name": "token_embeddings"
10
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "cls_token": "[CLS]",
4
+ "do_basic_tokenize": true,
5
+ "do_lower_case": true,
6
+ "is_local": false,
7
+ "local_files_only": false,
8
+ "mask_token": "[MASK]",
9
+ "max_length": 128,
10
+ "model_max_length": 256,
11
+ "never_split": null,
12
+ "pad_to_multiple_of": null,
13
+ "pad_token": "[PAD]",
14
+ "pad_token_type_id": 0,
15
+ "padding_side": "right",
16
+ "sep_token": "[SEP]",
17
+ "stride": 0,
18
+ "strip_accents": null,
19
+ "tokenize_chinese_chars": true,
20
+ "tokenizer_class": "BertTokenizer",
21
+ "truncation_side": "right",
22
+ "truncation_strategy": "longest_first",
23
+ "unk_token": "[UNK]"
24
+ }