Raphael Sourty commited on
Commit
7312eb7
1 Parent(s): a797db3
config.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "naver/splade_v2_max",
3
+ "activation": "gelu",
4
+ "architectures": [
5
+ "DistilBertForMaskedLM"
6
+ ],
7
+ "attention_dropout": 0.1,
8
+ "dim": 768,
9
+ "dropout": 0.1,
10
+ "hidden_dim": 3072,
11
+ "initializer_range": 0.02,
12
+ "max_position_embeddings": 512,
13
+ "model_type": "distilbert",
14
+ "n_heads": 12,
15
+ "n_layers": 6,
16
+ "output_hidden_states": true,
17
+ "pad_token_id": 0,
18
+ "qa_dropout": 0.1,
19
+ "seq_classif_dropout": 0.2,
20
+ "sinusoidal_pos_embds": false,
21
+ "tie_weights_": true,
22
+ "torch_dtype": "float32",
23
+ "transformers_version": "4.32.0",
24
+ "vocab_size": 30522
25
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6fef68f3b74d90f1923491464e84746bc02a8dce7abcb70a7d67dca0a313a72e
3
+ size 267978033
readme.md ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ ---
5
+
6
+ This model was trained with [Sparsembed](https://github.com/raphaelsty/sparsembed). You can find details on how to use it in the [Sparsembed](https://github.com/raphaelsty/sparsembed) repository.
7
+
8
+ ```sh
9
+ pip install sparsembed
10
+ ```
11
+
12
+ ```python
13
+ from sparsembed import model, retrieve
14
+ from transformers import AutoModelForMaskedLM, AutoTokenizer
15
+
16
+ device = "cuda" # cpu
17
+
18
+ batch_size = 10
19
+
20
+ # List documents to index:
21
+ documents = [
22
+ {'id': 0,
23
+ 'title': 'Paris',
24
+ 'url': 'https://en.wikipedia.org/wiki/Paris',
25
+ 'text': 'Paris is the capital and most populous city of France.'},
26
+ {'id': 1,
27
+ 'title': 'Paris',
28
+ 'url': 'https://en.wikipedia.org/wiki/Paris',
29
+ 'text': "Since the 17th century, Paris has been one of Europe's major centres of science, and arts."},
30
+ {'id': 2,
31
+ 'title': 'Paris',
32
+ 'url': 'https://en.wikipedia.org/wiki/Paris',
33
+ 'text': 'The City of Paris is the centre and seat of government of the region and province of Île-de-France.'
34
+ }]
35
+
36
+ model = model.Splade(
37
+ model=AutoModelForMaskedLM.from_pretrained("raphaelsty/splade_max").to(device),
38
+ tokenizer=AutoTokenizer.from_pretrained("raphaelsty/splade_max"),
39
+ device=device
40
+ )
41
+
42
+ retriever = retrieve.SpladeRetriever(
43
+ key="id", # Key identifier of each document.
44
+ on=["title", "text"], # Fields to search.
45
+ model=model # Splade retriever.
46
+ )
47
+
48
+ retriever = retriever.add(
49
+ documents=documents,
50
+ batch_size=batch_size,
51
+ k_tokens=256, # Number of activated tokens.
52
+ )
53
+
54
+ retriever(
55
+ ["paris", "Toulouse"], # Queries
56
+ k_tokens=20, # Maximum number of activated tokens.
57
+ k=100, # Number of documents to retrieve.
58
+ batch_size=batch_size
59
+ )
60
+ ```
special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "clean_up_tokenization_spaces": true,
3
+ "cls_token": "[CLS]",
4
+ "do_basic_tokenize": true,
5
+ "do_lower_case": true,
6
+ "mask_token": "[MASK]",
7
+ "model_max_length": 512,
8
+ "never_split": null,
9
+ "pad_token": "[PAD]",
10
+ "sep_token": "[SEP]",
11
+ "strip_accents": null,
12
+ "tokenize_chinese_chars": true,
13
+ "tokenizer_class": "DistilBertTokenizer",
14
+ "unk_token": "[UNK]"
15
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff