Osama-Rakan-Al-Mraikhat commited on
Commit
f28d4ea
·
verified ·
1 Parent(s): 6189104

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +35 -1
README.md CHANGED
@@ -2,7 +2,9 @@
2
  license: apache-2.0
3
  language:
4
  - ar
5
- library_name: transformers
 
 
6
  ---
7
  # AREEj: Arabic Relation Extraction with Evidence
8
  You can use AREEj to extract relations from Arabic documents. Each document can contain multiple relations, and each relation contains six elements, the source, target, their named entities, relation type between them, and evidence. The evidence is used for two reasons: improving the Relation Extraction task, and explaining the LLM's predictions. You can also use it as an edge between the related entities.
@@ -10,7 +12,39 @@ You can use AREEj to extract relations from Arabic documents. Each document can
10
  AREEj was introduced in the Proceedings of The Second Arabic Natural Language Processing Conference paper [AREEj: Arabic Relation Extraction with Evidence](https://aclanthology.org/2024.arabicnlp-1.6/).
11
 
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
 
14
  ```
15
  @inproceedings{mraikhat-etal-2024-areej,
16
  title = "{AREE}j: {A}rabic Relation Extraction with Evidence",
 
2
  license: apache-2.0
3
  language:
4
  - ar
5
+ tags:
6
+ - Relation Extraction
7
+ - Evidence Extraction
8
  ---
9
  # AREEj: Arabic Relation Extraction with Evidence
10
  You can use AREEj to extract relations from Arabic documents. Each document can contain multiple relations, and each relation contains six elements, the source, target, their named entities, relation type between them, and evidence. The evidence is used for two reasons: improving the Relation Extraction task, and explaining the LLM's predictions. You can also use it as an edge between the related entities.
 
12
  AREEj was introduced in the Proceedings of The Second Arabic Natural Language Processing Conference paper [AREEj: Arabic Relation Extraction with Evidence](https://aclanthology.org/2024.arabicnlp-1.6/).
13
 
14
 
15
+ ### How to use
16
+ ```
17
+ pip install transformers datasets evaluate transformers[torch]
18
+ pip install sentencepiece
19
+ ```
20
+ ```python
21
+ from transformers import MBartTokenizer, MBartForConditionalGeneration
22
+ import torch
23
+
24
+ tokenizer = MBartTokenizer.from_pretrained('dru-ac/AREEj', max_length=1024)
25
+ model = MBartForConditionalGeneration.from_pretrained('dru-ac/AREEj')
26
+ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
27
+
28
+ model.to(device)
29
+
30
+ def generate_prediction(input_text):
31
+ input_ids = tokenizer.encode(input_text, return_tensors="pt").to(device)
32
+ with torch.no_grad():
33
+ output = model.generate(
34
+ input_ids,
35
+ decoder_start_token_id=tokenizer.lang_code_to_id['ar_AR'],
36
+ )
37
+
38
+ prediction = tokenizer.decode(output[0], skip_special_tokens=False)
39
+
40
+ return prediction
41
+
42
+ input_text = 'تأسس المركز العربي للأبحاث ودراسة السياسات في عام 2010 في الدوحة في قطر'
43
+ prediction = generate_prediction(input_text)
44
+ print('Prediction:', prediction)
45
+ ```
46
 
47
+ ### If you use the code or model, please reference this work in your paper:
48
  ```
49
  @inproceedings{mraikhat-etal-2024-areej,
50
  title = "{AREE}j: {A}rabic Relation Extraction with Evidence",