Transformers
PyTorch
Vietnamese
mt5
text2text-generation
cherry0328 commited on
Commit
ebed214
·
verified ·
1 Parent(s): 1a8640b

Update README.md

Browse files

The nluai/qgv_v2_test1 model is truly impressive! We would love to contribute by updating the README to include the base_model information. This will help address the missing details in the model card.Thank you!

Files changed (1) hide show
  1. README.md +89 -82
README.md CHANGED
@@ -1,82 +1,89 @@
1
- ---
2
- language: vi
3
- datasets:
4
- - unicamp-dl/mmarco
5
- widget:
6
- - text: "Python (phát âm tiếng Anh: /ˈpaɪθɑːn/) là một ngôn ngữ lập trình bậc cao cho các mục đích lập trình đa năng, do Guido van Rossum tạo ra và lần đầu ra mắt vào năm 1991. Python được thiết kế với ưu điểm mạnh là dễ đọc, dễ học và dễ nhớ. Python là ngôn ngữ có hình thức rất sáng sủa, cấu trúc rõ ràng, thuận tiện cho người mới học lập trình và là ngôn ngữ lập trình dễ học; được dùng rộng rãi trong phát triển trí tuệ nhân tạo. Cấu trúc của Python còn cho phép người sử dụng viết mã lệnh với số lần gõ phím tối thiểu. Vào tháng 7 năm 2018, van Rossum đã từ chức lãnh đạo trong cộng đồng ngôn ngữ Python sau 30 năm làm việc."
7
-
8
- license: apache-2.0
9
- ---
10
-
11
- # doc2query/msmarco-vietnamese-mt5-base-v1
12
-
13
- This is a [doc2query](https://arxiv.org/abs/1904.08375) model based on mT5 (also known as [docT5query](https://cs.uwaterloo.ca/~jimmylin/publications/Nogueira_Lin_2019_docTTTTTquery-v2.pdf)).
14
-
15
- It can be used for:
16
- - **Document expansion**: You generate for your paragraphs 20-40 queries and index the paragraphs and the generates queries in a standard BM25 index like Elasticsearch, OpenSearch, or Lucene. The generated queries help to close the lexical gap of lexical search, as the generate queries contain synonyms. Further, it re-weights words giving important words a higher weight even if they appear seldomn in a paragraph. In our [BEIR](https://arxiv.org/abs/2104.08663) paper we showed that BM25+docT5query is a powerful search engine. In the [BEIR repository](https://github.com/beir-cellar/beir) we have an example how to use docT5query with Pyserini.
17
- - **Domain Specific Training Data Generation**: It can be used to generate training data to learn an embedding model. In our [GPL-Paper](https://arxiv.org/abs/2112.07577) / [GPL Example on SBERT.net](https://www.sbert.net/examples/domain_adaptation/README.html#gpl-generative-pseudo-labeling) we have an example how to use the model to generate (query, text) pairs for a given collection of unlabeled texts. These pairs can then be used to train powerful dense embedding models.
18
-
19
- ## Usage
20
- ```python
21
- from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
22
- import torch
23
-
24
- model_name = 'doc2query/msmarco-vietnamese-mt5-base-v1'
25
- tokenizer = AutoTokenizer.from_pretrained(model_name)
26
- model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
27
-
28
- text = "Python (phát âm tiếng Anh: /ˈpaɪθɑːn/) là một ngôn ngữ lập trình bậc cao cho các mục đích lập trình đa năng, do Guido van Rossum tạo ra và lần đầu ra mắt vào năm 1991. Python được thiết kế với ưu điểm mạnh là dễ đọc, dễ học và dễ nhớ. Python là ngôn ngữ có hình thức rất sáng sủa, cấu trúc rõ ràng, thuận tiện cho người mới học lập trình và là ngôn ngữ lập trình dễ học; được dùng rộng rãi trong phát triển trí tuệ nhân tạo. Cấu trúc của Python còn cho phép người sử dụng viết mã lệnh với số lần gõ phím tối thiểu. Vào tháng 7 năm 2018, van Rossum đã từ chức lãnh đạo trong cộng đồng ngôn ngữ Python sau 30 năm làm việc."
29
-
30
-
31
- def create_queries(para):
32
- input_ids = tokenizer.encode(para, return_tensors='pt')
33
- with torch.no_grad():
34
- # Here we use top_k / top_k random sampling. It generates more diverse queries, but of lower quality
35
- sampling_outputs = model.generate(
36
- input_ids=input_ids,
37
- max_length=64,
38
- do_sample=True,
39
- top_p=0.95,
40
- top_k=10,
41
- num_return_sequences=5
42
- )
43
-
44
- # Here we use Beam-search. It generates better quality queries, but with less diversity
45
- beam_outputs = model.generate(
46
- input_ids=input_ids,
47
- max_length=64,
48
- num_beams=5,
49
- no_repeat_ngram_size=2,
50
- num_return_sequences=5,
51
- early_stopping=True
52
- )
53
-
54
-
55
- print("Paragraph:")
56
- print(para)
57
-
58
- print("\nBeam Outputs:")
59
- for i in range(len(beam_outputs)):
60
- query = tokenizer.decode(beam_outputs[i], skip_special_tokens=True)
61
- print(f'{i + 1}: {query}')
62
-
63
- print("\nSampling Outputs:")
64
- for i in range(len(sampling_outputs)):
65
- query = tokenizer.decode(sampling_outputs[i], skip_special_tokens=True)
66
- print(f'{i + 1}: {query}')
67
-
68
- create_queries(text)
69
-
70
- ```
71
-
72
- **Note:** `model.generate()` is non-deterministic for top_k/top_n sampling. It produces different queries each time you run it.
73
-
74
- ## Training
75
- This model fine-tuned [google/mt5-base](https://huggingface.co/google/mt5-base) for 66k training steps (4 epochs on the 500k training pairs from MS MARCO). For the training script, see the `train_script.py` in this repository.
76
-
77
- The input-text was truncated to 320 word pieces. Output text was generated up to 64 word pieces.
78
-
79
- This model was trained on a (query, passage) from the [mMARCO dataset](https://github.com/unicamp-dl/mMARCO).
80
-
81
-
82
-
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: vi
3
+ datasets:
4
+ - unicamp-dl/mmarco
5
+ widget:
6
+ - text: >-
7
+ Python (phát âm tiếng Anh: /ˈpaɪθɑːn/) là một ngôn ngữ lập trình bậc cao cho
8
+ các mục đích lập trình đa năng, do Guido van Rossum tạo ra và lần đầu ra mắt
9
+ vào năm 1991. Python được thiết kế với ưu điểm mạnh là dễ đọc, dễ học và dễ
10
+ nhớ. Python là ngôn ngữ có hình thức rất sáng sủa, cấu trúc rõ ràng, thuận
11
+ tiện cho người mới học lập trình và là ngôn ngữ lập trình dễ học; được dùng
12
+ rộng rãi trong phát triển trí tuệ nhân tạo. Cấu trúc của Python còn cho phép
13
+ người sử dụng viết lệnh với số lần phím tối thiểu. Vào tháng 7 năm
14
+ 2018, van Rossum đã từ chức lãnh đạo trong cộng đồng ngôn ngữ Python sau 30
15
+ năm làm việc.
16
+ license: apache-2.0
17
+ base_model:
18
+ - google/mt5-base
19
+ ---
20
+
21
+ # doc2query/msmarco-vietnamese-mt5-base-v1
22
+
23
+ This is a [doc2query](https://arxiv.org/abs/1904.08375) model based on mT5 (also known as [docT5query](https://cs.uwaterloo.ca/~jimmylin/publications/Nogueira_Lin_2019_docTTTTTquery-v2.pdf)).
24
+
25
+ It can be used for:
26
+ - **Document expansion**: You generate for your paragraphs 20-40 queries and index the paragraphs and the generates queries in a standard BM25 index like Elasticsearch, OpenSearch, or Lucene. The generated queries help to close the lexical gap of lexical search, as the generate queries contain synonyms. Further, it re-weights words giving important words a higher weight even if they appear seldomn in a paragraph. In our [BEIR](https://arxiv.org/abs/2104.08663) paper we showed that BM25+docT5query is a powerful search engine. In the [BEIR repository](https://github.com/beir-cellar/beir) we have an example how to use docT5query with Pyserini.
27
+ - **Domain Specific Training Data Generation**: It can be used to generate training data to learn an embedding model. In our [GPL-Paper](https://arxiv.org/abs/2112.07577) / [GPL Example on SBERT.net](https://www.sbert.net/examples/domain_adaptation/README.html#gpl-generative-pseudo-labeling) we have an example how to use the model to generate (query, text) pairs for a given collection of unlabeled texts. These pairs can then be used to train powerful dense embedding models.
28
+
29
+ ## Usage
30
+ ```python
31
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
32
+ import torch
33
+
34
+ model_name = 'doc2query/msmarco-vietnamese-mt5-base-v1'
35
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
36
+ model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
37
+
38
+ text = "Python (phát âm tiếng Anh: /ˈpaɪθɑːn/) là một ngôn ngữ lập trình bậc cao cho các mục đích lập trình đa năng, do Guido van Rossum tạo ra và lần đầu ra mắt vào năm 1991. Python được thiết kế với ưu điểm mạnh là dễ đọc, dễ học và dễ nhớ. Python là ngôn ngữ có hình thức rất sáng sủa, cấu trúc rõ ràng, thuận tiện cho người mới học lập trình và là ngôn ngữ lập trình dễ học; được dùng rộng rãi trong phát triển trí tuệ nhân tạo. Cấu trúc của Python còn cho phép người sử dụng viết mã lệnh với số lần gõ phím tối thiểu. Vào tháng 7 năm 2018, van Rossum đã từ chức lãnh đạo trong cộng đồng ngôn ngữ Python sau 30 năm làm việc."
39
+
40
+
41
+ def create_queries(para):
42
+ input_ids = tokenizer.encode(para, return_tensors='pt')
43
+ with torch.no_grad():
44
+ # Here we use top_k / top_k random sampling. It generates more diverse queries, but of lower quality
45
+ sampling_outputs = model.generate(
46
+ input_ids=input_ids,
47
+ max_length=64,
48
+ do_sample=True,
49
+ top_p=0.95,
50
+ top_k=10,
51
+ num_return_sequences=5
52
+ )
53
+
54
+ # Here we use Beam-search. It generates better quality queries, but with less diversity
55
+ beam_outputs = model.generate(
56
+ input_ids=input_ids,
57
+ max_length=64,
58
+ num_beams=5,
59
+ no_repeat_ngram_size=2,
60
+ num_return_sequences=5,
61
+ early_stopping=True
62
+ )
63
+
64
+
65
+ print("Paragraph:")
66
+ print(para)
67
+
68
+ print("\nBeam Outputs:")
69
+ for i in range(len(beam_outputs)):
70
+ query = tokenizer.decode(beam_outputs[i], skip_special_tokens=True)
71
+ print(f'{i + 1}: {query}')
72
+
73
+ print("\nSampling Outputs:")
74
+ for i in range(len(sampling_outputs)):
75
+ query = tokenizer.decode(sampling_outputs[i], skip_special_tokens=True)
76
+ print(f'{i + 1}: {query}')
77
+
78
+ create_queries(text)
79
+
80
+ ```
81
+
82
+ **Note:** `model.generate()` is non-deterministic for top_k/top_n sampling. It produces different queries each time you run it.
83
+
84
+ ## Training
85
+ This model fine-tuned [google/mt5-base](https://huggingface.co/google/mt5-base) for 66k training steps (4 epochs on the 500k training pairs from MS MARCO). For the training script, see the `train_script.py` in this repository.
86
+
87
+ The input-text was truncated to 320 word pieces. Output text was generated up to 64 word pieces.
88
+
89
+ This model was trained on a (query, passage) from the [mMARCO dataset](https://github.com/unicamp-dl/mMARCO).