fabhiansan commited on
Commit
d74a0cd
·
verified ·
1 Parent(s): a6e3aaa

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +83 -0
README.md ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # `indoT5-AMRToTextGenerator-V1.1`
3
+ Model ini adalah versi *fine-tuned* tugas generasi teks dari Abstract Meaning Representation (AMR) dalam Bahasa Indonesia.
4
+ Proses *fine-tuning* dilakukan dengan menggunakan Dataset Augemnted dari AMRParser abdiharyadi/taufiq-indo-amr-generation-gold-v1.1-uncased terhadap XSum Indonesia.
5
+
6
+ **Bahasa Utama:** Indonesia
7
+
8
+
9
+ ## Tujuan Penggunaan
10
+
11
+ * **Penggunaan Utama:** Model ini ditujukan untuk mengubah representasi AMR (Abstract Meaning Representation) dalam Bahasa Indonesia menjadi teks naratif yang dapat dibaca manusia. Ini bisa berguna untuk aplikasi seperti peringkasan teks berbasis AMR, augmentasi data, atau alat bantu pemahaman struktur semantik.
12
+
13
+
14
+ ## Cara Penggunaan
15
+ ```python
16
+ from transformers import T5TokenizerFast, AutoModelForSeq2SeqLM
17
+ import torch
18
+
19
+ model_path = "fabhiansan/indoT5-AMRToTextGenerator"
20
+ tokenizer_path = "fabhiansan/indoT5-AMRToTextGenerator"
21
+
22
+ tokenizer = T5TokenizerFast.from_pretrained(tokenizer_path)
23
+ model = AutoModelForSeq2SeqLM.from_pretrained(model_path)
24
+
25
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
26
+ model.to(device)
27
+ model.eval() # Set model ke mode evaluasi
28
+
29
+ contoh_amr = """
30
+ (w / want-01
31
+ :ARG0 (b / boy)
32
+ :ARG1 (g / go-01
33
+ :ARG0 b
34
+ :ARG2 (c / cinema)))
35
+ """
36
+ prefix = "translate graph to indonesian: "
37
+ input_text = prefix + contoh_amr.strip() # Hilangkan spasi berlebih di awal/akhir
38
+
39
+ inputs = tokenizer(
40
+ input_text,
41
+ return_tensors='pt',
42
+ padding=True,
43
+ truncation=True,
44
+ max_length=512
45
+ )
46
+
47
+ inputs = {k: v.to(device) for k, v in inputs.items()}
48
+
49
+ print("Melakukan generasi teks...")
50
+ with torch.no_grad(): # Tidak perlu menghitung gradien saat inferensi
51
+ outputs = model.generate(
52
+ input_ids=inputs['input_ids'],
53
+ attention_mask=inputs['attention_mask'],
54
+ max_length=512, # Max length untuk output yang digenerasi
55
+ num_beams=5, # Contoh parameter beam search
56
+ repetition_penalty=2.5,
57
+ length_penalty=1.0,
58
+ early_stopping=True
59
+ )
60
+
61
+ generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
62
+
63
+ print("\nInput AMR:")
64
+ print(contoh_amr)
65
+ print("\nGenerated Indonesian Text:")
66
+ print(generated_text)
67
+ ```
68
+
69
+
70
+ **Penelitian terkait (Daryanto dan Khodra, 2022):**
71
+ ```bibtex
72
+ @INPROCEEDINGS{9932960,
73
+ author={Daryanto, Taufiq Husada and Khodra, Masayu Leylia},
74
+ booktitle={2022 9th International Conference on Advanced Informatics: Concepts, Theory and Applications (ICAICTA)},
75
+ title={Indonesian AMR-to-Text Generation by Language Model Fine-tuning},
76
+ year={2022},
77
+ volume={},
78
+ number={},
79
+ pages={1-6},
80
+ doi={10.1109/ICAICTA56449.2022.9932960}
81
+ }
82
+ ```
83
+