jiaxin-wen commited on
Commit
68bb171
1 Parent(s): 8e92dea
README.md ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This model has been trained on massive Chinese plain-text open-domain dialogues following the approach described in [Re$^3$Dial: Retrieve, Reorganize and Rescale Conversations for Long-Turn Open-Domain Dialogue Pre-training](https://arxiv.org/abs/2305.02606). The associated Github repository is available here https://github.com/thu-coai/Re3Dial.
2
+
3
+ ### Usage
4
+
5
+ ```python
6
+ from transformers import BertTokenizer, BertModel
7
+ import torch
8
+
9
+
10
+ def get_embedding(encoder, inputs):
11
+ outputs = encoder(**inputs)
12
+ pooled_output = outputs[0][:, 0, :]
13
+ return pooled_output
14
+
15
+ tokenizer = BertTokenizer.from_pretrained('xwwwww/bert-chinese-dialogue-retriever-query')
16
+ tokenizer.add_tokens(['<uttsep>'])
17
+ query_encoder = BertModel.from_pretrained('xwwwww/bert-chinese-dialogue-retriever-query')
18
+ context_encoder = BertModel.from_pretrained('xwwwww/bert-chinese-dialogue-retriever-context')
19
+
20
+ query = '你好<uttsep>好久不见,最近在干嘛'
21
+ context = '正在准备考试<uttsep>是什么考试呀,很辛苦吧'
22
+
23
+ query_inputs = tokenizer([query], return_tensors='pt')
24
+ context_inputs = tokenizer([context], return_tensors='pt')
25
+
26
+ query_embedding = get_embedding(query_encoder, query_inputs)
27
+ context_embedding = get_embedding(context_encoder, context_inputs)
28
+
29
+ score = torch.cosine_similarity(query_embedding, context_embedding, dim=1)
30
+
31
+ print('similarity score = ', score)
32
+ ```
added_tokens.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {}
config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BertForMaskedLM"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "bos_token_id": 0,
7
+ "directionality": "bidi",
8
+ "eos_token_id": 2,
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_past": true,
20
+ "pad_token_id": 1,
21
+ "pooler_fc_size": 768,
22
+ "pooler_num_attention_heads": 12,
23
+ "pooler_num_fc_layers": 3,
24
+ "pooler_size_per_head": 128,
25
+ "pooler_type": "first_token_transform",
26
+ "type_vocab_size": 2,
27
+ "vocab_size": 21129
28
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3f29bd3a31022813466042d30c9391714dcb57a72d362855e21bccf7682f8dec
3
+ size 409141297
special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"init_inputs": []}
vocab.txt ADDED
The diff for this file is too large to render. See raw diff