Update README.md
Browse files
README.md
CHANGED
@@ -50,7 +50,41 @@ Although this model performs well and is state-of-the-art for now. But still thi
|
|
50 |
|
51 |
## How to Get Started with the Model
|
52 |
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
|
56 |
|
@@ -68,7 +102,6 @@ MRR @10 : 0.247
|
|
68 |
|
69 |
|
70 |
### Results
|
71 |
-
## Detailed Results
|
72 |
|
73 |
| Model | Name | Data | Recall@10 | MRR@10 | Queries Ranked |
|
74 |
|---------------------------------------|---------------------------------------|--------------|-----------|--------|----------------|
|
@@ -79,46 +112,22 @@ MRR @10 : 0.247
|
|
79 |
| This work | Mavkif/urdu-mt5-mmarco | Urdu data | 0.438 | 0.247 | 6980 |
|
80 |
|
81 |
|
82 |
-
#### Summary
|
83 |
|
84 |
|
85 |
|
86 |
### Model Architecture and Objective
|
87 |
-
From config.json :
|
88 |
-
|
89 |
{
|
90 |
-
|
91 |
-
|
92 |
-
"
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
"dense_act_fn": "gelu_new",
|
100 |
-
"dropout_rate": 0.1,
|
101 |
-
"eos_token_id": 1,
|
102 |
-
"feed_forward_proj": "gated-gelu",
|
103 |
-
"initializer_factor": 1.0,
|
104 |
-
"is_encoder_decoder": true,
|
105 |
-
"is_gated_act": true,
|
106 |
-
"layer_norm_epsilon": 1e-06,
|
107 |
-
"model_type": "mt5",
|
108 |
-
"num_decoder_layers": 12,
|
109 |
-
"num_heads": 12,
|
110 |
-
"num_layers": 12,
|
111 |
-
"output_past": true,
|
112 |
-
"pad_token_id": 0,
|
113 |
-
"relative_attention_max_distance": 128,
|
114 |
-
"relative_attention_num_buckets": 32,
|
115 |
-
"tie_word_embeddings": false,
|
116 |
-
"tokenizer_class": "T5Tokenizer",
|
117 |
-
"torch_dtype": "float32",
|
118 |
-
"transformers_version": "4.38.2",
|
119 |
-
"use_cache": true,
|
120 |
-
"vocab_size": 250112
|
121 |
}
|
|
|
122 |
|
123 |
|
124 |
## Model Card Authors [optional]
|
|
|
50 |
|
51 |
## How to Get Started with the Model
|
52 |
|
53 |
+
Example Code for Scoring Query-Document Pairs:
|
54 |
+
In an IR setting, you provide a query and one or more candidate documents. The model scores each document for relevance to the query, which can be used for ranking.
|
55 |
+
```
|
56 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
57 |
+
import torch
|
58 |
+
|
59 |
+
# Load the tokenizer and model
|
60 |
+
tokenizer = AutoTokenizer.from_pretrained("Mavkif/urdu-mt5-mmarco")
|
61 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("Mavkif/urdu-mt5-mmarco")
|
62 |
+
|
63 |
+
# Define the query and candidate documents
|
64 |
+
query = "پاکستان کی معیشت کی موجودہ صورتحال کیا ہے؟"
|
65 |
+
document_1 = "پاکستان کی معیشت میں حالیہ ترقی کے بارے میں معلومات۔"
|
66 |
+
document_2 = "فٹبال پاکستان میں تیزی سے مقبول ہو رہا ہے۔"
|
67 |
+
|
68 |
+
# Tokenize query-document pairs and calculate relevance scores
|
69 |
+
def get_score(query, document):
|
70 |
+
input_text = f"Query: {query} Document: {document}"
|
71 |
+
inputs = tokenizer(input_text, return_tensors="pt", truncation=True)
|
72 |
+
|
73 |
+
# Pass through the model and get the relevance score (logits)
|
74 |
+
outputs = model(**inputs)
|
75 |
+
score = outputs.logits[0, -1, :] # last token logits
|
76 |
+
return torch.softmax(score, dim=0)[tokenizer.eos_token_id].item()
|
77 |
+
|
78 |
+
# Get scores for each document
|
79 |
+
score_1 = get_score(query, document_1)
|
80 |
+
score_2 = get_score(query, document_2)
|
81 |
+
|
82 |
+
print(f"Relevance Score for Document 1: {score_1}")
|
83 |
+
print(f"Relevance Score for Document 2: {score_2}")
|
84 |
+
|
85 |
+
# Higher score indicates higher relevance
|
86 |
+
|
87 |
+
```
|
88 |
|
89 |
|
90 |
|
|
|
102 |
|
103 |
|
104 |
### Results
|
|
|
105 |
|
106 |
| Model | Name | Data | Recall@10 | MRR@10 | Queries Ranked |
|
107 |
|---------------------------------------|---------------------------------------|--------------|-----------|--------|----------------|
|
|
|
112 |
| This work | Mavkif/urdu-mt5-mmarco | Urdu data | 0.438 | 0.247 | 6980 |
|
113 |
|
114 |
|
|
|
115 |
|
116 |
|
117 |
|
118 |
### Model Architecture and Objective
|
|
|
|
|
119 |
{
|
120 |
+
"_name_or_path": "unicamp-dl/mt5-base-mmarco-v2",
|
121 |
+
"architectures": ["MT5ForConditionalGeneration"],
|
122 |
+
"d_model": 768,
|
123 |
+
"num_heads": 12,
|
124 |
+
"num_layers": 12,
|
125 |
+
"dropout_rate": 0.1,
|
126 |
+
"vocab_size": 250112,
|
127 |
+
"model_type": "mt5",
|
128 |
+
"transformers_version": "4.38.2"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
}
|
130 |
+
For more details on how to customize the decoding parameters (such as max_length, num_beams, and early_stopping), refer to the Hugging Face documentation.
|
131 |
|
132 |
|
133 |
## Model Card Authors [optional]
|