First commit
Browse files- README.md +54 -0
- config.json +61 -0
README.md
CHANGED
|
@@ -1,3 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: cc-by-4.0
|
| 3 |
---
|
|
|
|
| 1 |
+
|
| 2 |
+
# TRL Model
|
| 3 |
+
|
| 4 |
+
This is a [TRL language model](https://github.com/huggingface/trl) that has been fine-tuned with reinforcement learning to guide the model outputs according to a value, function, or human feedback. The model can be used for text generation.
|
| 5 |
+
|
| 6 |
+
## Usage
|
| 7 |
+
|
| 8 |
+
This model is a part of a study explained here on document expansion using Doc2Query. Please cite the paper if you use it.
|
| 9 |
+
To use this model for inference, first install the TRL library:
|
| 10 |
+
|
| 11 |
+
```bash
|
| 12 |
+
pip install trl
|
| 13 |
+
```
|
| 14 |
+
|
| 15 |
+
You can then generate text as follows:
|
| 16 |
+
|
| 17 |
+
```python
|
| 18 |
+
from transformers import pipeline
|
| 19 |
+
|
| 20 |
+
generator = pipeline("text-generation", model="watheq/d2q_monoELECTRA_1400")
|
| 21 |
+
outputs = generator("Hello, my llama is cute")
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
If you want to use the model for training or to obtain the outputs from the value head, load the model as follows:
|
| 25 |
+
|
| 26 |
+
```python
|
| 27 |
+
from transformers import AutoTokenizer
|
| 28 |
+
from trl import AutoModelForCausalLMWithValueHead
|
| 29 |
+
|
| 30 |
+
tokenizer = AutoTokenizer.from_pretrained("watheq/d2q_monoELECTRA_1400")
|
| 31 |
+
model = AutoModelForCausalLMWithValueHead.from_pretrained("watheq/d2q_monoELECTRA_1400")
|
| 32 |
+
|
| 33 |
+
inputs = tokenizer("Coffee is a beverage brewed from roasted coffee beans. Coffee has a stimulating effect on humans, primarily due to its caffeine content.", return_tensors="pt")
|
| 34 |
+
outputs = model(**inputs, labels=inputs["input_ids"])
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
## Citation
|
| 40 |
+
|
| 41 |
+
If you used any piece of this repository, please consider citing our work :
|
| 42 |
+
|
| 43 |
+
```plaintext
|
| 44 |
+
@inproceedings{mansour2024revisit,
|
| 45 |
+
title={Revisiting Document Expansion and Filtering for Effective First-Stage Retrieval},
|
| 46 |
+
author={Mansour, Watheq and Zhuang, Shengyao and Zhuang, Guido and Mackenzie, Joel},
|
| 47 |
+
booktitle = {Proceedings of the 47th International ACM SIGIR Conference on Research and Development in Information Retrieval},
|
| 48 |
+
year={2024},
|
| 49 |
+
publisher = {Association for Computing Machinery},
|
| 50 |
+
series = {SIGIR '24}
|
| 51 |
+
}
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
|
| 55 |
---
|
| 56 |
license: cc-by-4.0
|
| 57 |
---
|
config.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "castorini/doc2query-t5-base-msmarco",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"T5ForConditionalGeneration"
|
| 5 |
+
],
|
| 6 |
+
"classifier_dropout": 0.0,
|
| 7 |
+
"d_ff": 3072,
|
| 8 |
+
"d_kv": 64,
|
| 9 |
+
"d_model": 768,
|
| 10 |
+
"decoder_start_token_id": 0,
|
| 11 |
+
"dense_act_fn": "relu",
|
| 12 |
+
"dropout_rate": 0.1,
|
| 13 |
+
"eos_token_id": 1,
|
| 14 |
+
"feed_forward_proj": "relu",
|
| 15 |
+
"initializer_factor": 1.0,
|
| 16 |
+
"is_encoder_decoder": true,
|
| 17 |
+
"is_gated_act": false,
|
| 18 |
+
"layer_norm_epsilon": 1e-06,
|
| 19 |
+
"model_type": "t5",
|
| 20 |
+
"n_positions": 512,
|
| 21 |
+
"num_decoder_layers": 12,
|
| 22 |
+
"num_heads": 12,
|
| 23 |
+
"num_layers": 12,
|
| 24 |
+
"output_past": true,
|
| 25 |
+
"pad_token_id": 0,
|
| 26 |
+
"relative_attention_max_distance": 128,
|
| 27 |
+
"relative_attention_num_buckets": 32,
|
| 28 |
+
"task_specific_params": {
|
| 29 |
+
"summarization": {
|
| 30 |
+
"early_stopping": true,
|
| 31 |
+
"length_penalty": 2.0,
|
| 32 |
+
"max_length": 200,
|
| 33 |
+
"min_length": 30,
|
| 34 |
+
"no_repeat_ngram_size": 3,
|
| 35 |
+
"num_beams": 4,
|
| 36 |
+
"prefix": "summarize: "
|
| 37 |
+
},
|
| 38 |
+
"translation_en_to_de": {
|
| 39 |
+
"early_stopping": true,
|
| 40 |
+
"max_length": 300,
|
| 41 |
+
"num_beams": 4,
|
| 42 |
+
"prefix": "translate English to German: "
|
| 43 |
+
},
|
| 44 |
+
"translation_en_to_fr": {
|
| 45 |
+
"early_stopping": true,
|
| 46 |
+
"max_length": 300,
|
| 47 |
+
"num_beams": 4,
|
| 48 |
+
"prefix": "translate English to French: "
|
| 49 |
+
},
|
| 50 |
+
"translation_en_to_ro": {
|
| 51 |
+
"early_stopping": true,
|
| 52 |
+
"max_length": 300,
|
| 53 |
+
"num_beams": 4,
|
| 54 |
+
"prefix": "translate English to Romanian: "
|
| 55 |
+
}
|
| 56 |
+
},
|
| 57 |
+
"torch_dtype": "float32",
|
| 58 |
+
"transformers_version": "4.35.2",
|
| 59 |
+
"use_cache": true,
|
| 60 |
+
"vocab_size": 32128
|
| 61 |
+
}
|