vaishali commited on
Commit
11aa1ae
1 Parent(s): 2fd96cf

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +95 -3
README.md CHANGED
@@ -1,3 +1,95 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ ---
4
+
5
+ # Usage
6
+ ```python
7
+ import pandas as pd
8
+ from datasets import load_dataset
9
+ from transformers import MBartForConditionalGeneration
10
+ model = MBartForConditionalGeneration.from_pretrained("vaishali/BnTQA-mBart")
11
+ tokenizer = AutoTokenizer.from_pretrained(args.pretrained_model_name, src_lang="bn_IN", tgt_lang="bn_IN")
12
+ forced_bos_id = forced_bos_token_id = tokenizer.lang_code_to_id["bn_IN"]
13
+
14
+
15
+ # linearize table
16
+ def process_header(headers: List):
17
+ return "<কলাম> " + " | ".join(headers)
18
+
19
+ def process_row(row: List, row_index: int):
20
+ en2bnDigits = {'0': '০', '1': '১', '2': '২', '3': '৩', '4': '৪', '5': '৫', '6': '৬', '7': '৭', '8': '৮', '9': '৯', '.': '.'}
21
+ row_str = ""
22
+ row_cell_values = []
23
+ for cell_value in row:
24
+ if isinstance(cell_value, int) or isinstance(cell_value, float):
25
+ cell_value = self.convert_engDigit_to_bengali(str(cell_value))
26
+ row_cell_values.append(str(cell_value))
27
+ else:
28
+ row_cell_values.append(cell_value)
29
+ row_str += " | ".join([row_cell_values for cell_value in row])
30
+ bn_row_index = []
31
+ for c in str(row_index):
32
+ bn_row_index.append(en2bnDigits[c])
33
+ return "<রো " + "".join(bn_row_index) + "> " + row_str
34
+
35
+ def process_table(table_content: Dict):
36
+ table_str = process_header(table_content["header"]) + " "
37
+ for i, row_example in enumerate(table_content["rows"]):
38
+ table_str += self.process_row(row_example, row_index=i + 1) + " "
39
+ return table_str.strip()
40
+
41
+ # load the dataset
42
+ banglatableQA = load_dataset("vaishali/banglaTabQA")
43
+
44
+ for sample in banglatableQA['train']:
45
+ question = sample['question']
46
+ input_table = pd.read_json(sample['table'], orient='split')
47
+ answer = pd.read_json(sample['answer'], orient='split')
48
+
49
+ # create the input sequence: query + linearized input table
50
+ table_content = {"header": list(input_table.columns)[1:], "rows": [list(row.values)[1:] for i, row in input_table.iterrows()]}
51
+ linearized_inp_table = process_table(table_content)
52
+ linearized_output_table = process_table({"name": None, "header": [self.translate_column(col) for col in list(answer.columns)],
53
+ "rows": [list(row.values) for i, row in answer.iterrows()]})
54
+ source = query + " " + linearized_inp_table
55
+ target = linearized_output_table
56
+ input = tokenizer(source,
57
+ return_tensors="pt",
58
+ padding="max_length",
59
+ truncation="longest_first",
60
+ max_length=1024,
61
+ add_special_tokens=True)
62
+
63
+ with tokenizer.as_target_tokenizer():
64
+ labels = tokenizer(target,
65
+ return_tensors="pt",
66
+ padding="max_length",
67
+ truncation="longest_first",
68
+ max_length=1024,
69
+ add_special_tokens=True).input_ids
70
+
71
+ # inference
72
+ out = model(**input)
73
+ ```
74
+ # BibTeX entry and citation info
75
+ ```
76
+ @inproceedings{pal-etal-2024-table,
77
+ title = "Table Question Answering for Low-resourced {I}ndic Languages",
78
+ author = "Pal, Vaishali and
79
+ Kanoulas, Evangelos and
80
+ Yates, Andrew and
81
+ de Rijke, Maarten",
82
+ editor = "Al-Onaizan, Yaser and
83
+ Bansal, Mohit and
84
+ Chen, Yun-Nung",
85
+ booktitle = "Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing",
86
+ month = nov,
87
+ year = "2024",
88
+ address = "Miami, Florida, USA",
89
+ publisher = "Association for Computational Linguistics",
90
+ url = "https://aclanthology.org/2024.emnlp-main.5",
91
+ pages = "75--92",
92
+ abstract = "TableQA is the task of answering questions over tables of structured information, returning individual cells or tables as output. TableQA research has focused primarily on high-resource languages, leaving medium- and low-resource languages with little progress due to scarcity of annotated data and neural models. We address this gap by introducing a fully automatic large-scale tableQA data generation process for low-resource languages with limited budget. We incorporate our data generation method on two Indic languages, Bengali and Hindi, which have no tableQA datasets or models. TableQA models trained on our large-scale datasets outperform state-of-the-art LLMs. We further study the trained models on different aspects, including mathematical reasoning capabilities and zero-shot cross-lingual transfer. Our work is the first on low-resource tableQA focusing on scalable data generation and evaluation procedures. Our proposed data generation method can be applied to any low-resource language with a web presence. We release datasets, models, and code (https://github.com/kolk/Low-Resource-TableQA-Indic-languages).",
93
+ }
94
+
95
+ ```