ldwang commited on
Commit
58de04a
1 Parent(s): 7f35c90
1_Pooling/config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 1024,
3
+ "pooling_mode_cls_token": true,
4
+ "pooling_mode_mean_tokens": false,
5
+ "pooling_mode_max_tokens": false,
6
+ "pooling_mode_mean_sqrt_len_tokens": false
7
+ }
README.md ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ # flag-text-embedding-chinese
4
+
5
+ Map any text to a 1024-dimensional dense vector space and can be used for tasks like retrieval, classification, clustering, or semantic search.
6
+
7
+
8
+
9
+ ## Usage (Sentence-Transformers)
10
+
11
+ Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
12
+
13
+ ```
14
+ pip install -U sentence-transformers
15
+ ```
16
+
17
+ Then you can use the model like this:
18
+
19
+ ```python
20
+ from sentence_transformers import SentenceTransformer
21
+ sentences = ["样例数据-1", "样例数据-2"]
22
+
23
+ model = SentenceTransformer('Shitao/flag-text-embedding-chinese')
24
+ embeddings = model.encode(sentences, normalize_embeddings=True)
25
+ print(embeddings)
26
+ ```
27
+
28
+
29
+
30
+ ## Usage (HuggingFace Transformers)
31
+ Without [sentence-transformers](https://www.SBERT.net), you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.
32
+
33
+ ```python
34
+ from transformers import AutoTokenizer, AutoModel
35
+ import torch
36
+
37
+
38
+ # Sentences we want sentence embeddings for
39
+ sentences = ["样例数据-1", "样例数据-2"]
40
+
41
+ # Load model from HuggingFace Hub
42
+ tokenizer = AutoTokenizer.from_pretrained('Shitao/flag-text-embedding-chinese')
43
+ model = AutoModel.from_pretrained('Shitao/flag-text-embedding-chinese')
44
+
45
+ # Tokenize sentences
46
+ encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
47
+
48
+ # Compute token embeddings
49
+ with torch.no_grad():
50
+ model_output = model(**encoded_input)
51
+ # Perform pooling. In this case, cls pooling.
52
+ sentence_embeddings = model_output[0][:, 0]
53
+
54
+ print("Sentence embeddings:")
55
+ print(sentence_embeddings)
56
+ ```
57
+
58
+
59
+
60
+ ## Evaluation Results
61
+
62
+ For an automated evaluation of this model, see the *Chinese Embedding Benchmark*: [link]()
63
+
64
+
65
+
66
+
67
+ ## Citing & Authors
68
+
69
+ <!--- Describe where people can find more information -->
config.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/share/models/ours/zh/finetune/v3_post_finetune_filter_prompt",
3
+ "architectures": [
4
+ "BertModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "bos_token_id": 0,
8
+ "classifier_dropout": null,
9
+ "directionality": "bidi",
10
+ "eos_token_id": 2,
11
+ "hidden_act": "gelu",
12
+ "hidden_dropout_prob": 0.1,
13
+ "hidden_size": 1024,
14
+ "id2label": {
15
+ "0": "LABEL_0"
16
+ },
17
+ "initializer_range": 0.02,
18
+ "intermediate_size": 4096,
19
+ "label2id": {
20
+ "LABEL_0": 0
21
+ },
22
+ "layer_norm_eps": 1e-12,
23
+ "max_position_embeddings": 512,
24
+ "model_type": "bert",
25
+ "num_attention_heads": 16,
26
+ "num_hidden_layers": 24,
27
+ "output_past": true,
28
+ "pad_token_id": 0,
29
+ "pooler_fc_size": 768,
30
+ "pooler_num_attention_heads": 12,
31
+ "pooler_num_fc_layers": 3,
32
+ "pooler_size_per_head": 128,
33
+ "pooler_type": "first_token_transform",
34
+ "position_embedding_type": "absolute",
35
+ "torch_dtype": "float32",
36
+ "transformers_version": "4.28.1",
37
+ "type_vocab_size": 2,
38
+ "use_cache": true,
39
+ "vocab_size": 21128
40
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.2.2",
4
+ "transformers": "4.28.1",
5
+ "pytorch": "1.13.0+cu117"
6
+ }
7
+ }
modules.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": "",
6
+ "type": "sentence_transformers.models.Transformer"
7
+ },
8
+ {
9
+ "idx": 1,
10
+ "name": "1",
11
+ "path": "1_Pooling",
12
+ "type": "sentence_transformers.models.Pooling"
13
+ }
14
+ ]
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:837df24cd1be597c6a149e3a051019c271dda0c7aa3f358eff74f9dc73c56c47
3
+ size 1302220525
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 512,
3
+ "do_lower_case": true
4
+ }
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": 1000000000000000019884624838656,
8
+ "never_split": null,
9
+ "pad_token": "[PAD]",
10
+ "sep_token": "[SEP]",
11
+ "strip_accents": null,
12
+ "tokenize_chinese_chars": true,
13
+ "tokenizer_class": "BertTokenizer",
14
+ "unk_token": "[UNK]"
15
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff