Raphael Sourty
commited on
upload model
Browse files- README.md +61 -0
- config.json +27 -0
- generation_config.json +5 -0
- linear.pt +3 -0
- metadata.json +10 -0
- model.safetensors +3 -0
- special_tokens_map.json +7 -0
- tokenizer.json +0 -0
- tokenizer_config.json +58 -0
- vocab.txt +0 -0
README.md
CHANGED
|
@@ -1,3 +1,64 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
| 2 |
license: mit
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
license: mit
|
| 5 |
---
|
| 6 |
+
|
| 7 |
+
This model was trained with [Neural-Cherche](https://github.com/raphaelsty/neural-cherche). You can find details on how to fine-tune it in the [Neural-Cherche](https://github.com/raphaelsty/neural-cherche) repository.
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
```sh
|
| 11 |
+
pip install neural-cherche
|
| 12 |
+
```
|
| 13 |
+
|
| 14 |
+
## Retriever
|
| 15 |
+
|
| 16 |
+
```python
|
| 17 |
+
from neural_cherche import models, retrieve
|
| 18 |
+
import torch
|
| 19 |
+
|
| 20 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 21 |
+
batch_size = 32
|
| 22 |
+
|
| 23 |
+
documents = [
|
| 24 |
+
{"id": 0, "document": "Food"},
|
| 25 |
+
{"id": 1, "document": "Sports"},
|
| 26 |
+
{"id": 2, "document": "Cinema"},
|
| 27 |
+
]
|
| 28 |
+
|
| 29 |
+
queries = ["Food", "Sports", "Cinema"]
|
| 30 |
+
|
| 31 |
+
model = SparseEmbed(
|
| 32 |
+
model_name_or_path="raphaelsty/neural-cherche-sparse-embed",
|
| 33 |
+
device=device,
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
retriever = retrieve.SparseEmbed(
|
| 37 |
+
key="id",
|
| 38 |
+
on=["document"],
|
| 39 |
+
model=model,
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
documents_embeddings = retriever.encode_documents(
|
| 43 |
+
documents=documents,
|
| 44 |
+
batch_size=batch_size,
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
retriever = retriever.add(
|
| 48 |
+
documents_embeddings=documents_embeddings,
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
queries_embeddings = retriever.encode_queries(
|
| 52 |
+
queries=queries,
|
| 53 |
+
batch_size=batch_size,
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
scores = retriever(
|
| 57 |
+
queries_embeddings=queries_embeddings,
|
| 58 |
+
batch_size=batch_size,
|
| 59 |
+
k=100,
|
| 60 |
+
k_ranker=10,
|
| 61 |
+
)
|
| 62 |
+
|
| 63 |
+
scores
|
| 64 |
+
```
|
config.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "raphaelsty/neural-cherche-sparse-embed",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"BertForMaskedLM"
|
| 5 |
+
],
|
| 6 |
+
"attention_probs_dropout_prob": 0.1,
|
| 7 |
+
"classifier_dropout": null,
|
| 8 |
+
"gradient_checkpointing": false,
|
| 9 |
+
"hidden_act": "gelu",
|
| 10 |
+
"hidden_dropout_prob": 0.1,
|
| 11 |
+
"hidden_size": 768,
|
| 12 |
+
"initializer_range": 0.02,
|
| 13 |
+
"intermediate_size": 3072,
|
| 14 |
+
"layer_norm_eps": 1e-12,
|
| 15 |
+
"max_position_embeddings": 512,
|
| 16 |
+
"model_type": "bert",
|
| 17 |
+
"num_attention_heads": 12,
|
| 18 |
+
"num_hidden_layers": 12,
|
| 19 |
+
"output_hidden_states": true,
|
| 20 |
+
"pad_token_id": 0,
|
| 21 |
+
"position_embedding_type": "absolute",
|
| 22 |
+
"torch_dtype": "float32",
|
| 23 |
+
"transformers_version": "4.35.2",
|
| 24 |
+
"type_vocab_size": 2,
|
| 25 |
+
"use_cache": true,
|
| 26 |
+
"vocab_size": 30522
|
| 27 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"pad_token_id": 0,
|
| 4 |
+
"transformers_version": "4.35.2"
|
| 5 |
+
}
|
linear.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2cd1265d36bedccc9ef3e4329d46510010a908257867a21840e46ec8c3a45f9f
|
| 3 |
+
size 394391
|
metadata.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"max_length_query": 64,
|
| 3 |
+
"max_length_document": 256,
|
| 4 |
+
"query_prefix": "",
|
| 5 |
+
"document_prefix": "",
|
| 6 |
+
"padding": "max_length",
|
| 7 |
+
"truncation": true,
|
| 8 |
+
"add_special_tokens": true,
|
| 9 |
+
"n_mask_tokens": 3
|
| 10 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f28d2cd97f79d1a6d5f6ef3a4f2e5e022b9c293dd982e29c7cc21ef9dfe9bbfd
|
| 3 |
+
size 438080896
|
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,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"0": {
|
| 4 |
+
"content": "[PAD]",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"100": {
|
| 12 |
+
"content": "[UNK]",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"101": {
|
| 20 |
+
"content": "[CLS]",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"102": {
|
| 28 |
+
"content": "[SEP]",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"103": {
|
| 36 |
+
"content": "[MASK]",
|
| 37 |
+
"lstrip": false,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
"clean_up_tokenization_spaces": true,
|
| 45 |
+
"cls_token": "[CLS]",
|
| 46 |
+
"device": "cuda",
|
| 47 |
+
"do_basic_tokenize": true,
|
| 48 |
+
"do_lower_case": true,
|
| 49 |
+
"mask_token": "[MASK]",
|
| 50 |
+
"model_max_length": 512,
|
| 51 |
+
"never_split": null,
|
| 52 |
+
"pad_token": "[PAD]",
|
| 53 |
+
"sep_token": "[SEP]",
|
| 54 |
+
"strip_accents": null,
|
| 55 |
+
"tokenize_chinese_chars": true,
|
| 56 |
+
"tokenizer_class": "BertTokenizer",
|
| 57 |
+
"unk_token": "[UNK]"
|
| 58 |
+
}
|
vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|