Views
No views yet
| Language | Accuracy (%) | F1 Score (%) | Precision (%) | Recall (%) |
|---|---|---|---|---|
| Malay + English | 64.8 | 74.0 | 65.3 | 85.3 |
| Malay | 64.3 | 73.6 | 64.6 | 85.4 |
bf16 parameter to True to optimize compute efficiency without significantly sacrificing model accuracy.gradient_accumulation_steps to deal with the small GPU constraints or increase the batch_size if we've access to a larger GPU. The reasoning is mainly to avoid Out of Memory Errors (OOM).patience variable and train for more than 10 epochs.1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM, \
3 BitsAndBytesConfig, pipeline
4
5TORCH_DTYPE = 'bfloat16'
6
7nf4_config = BitsAndBytesConfig(
8 load_in_4bit=True,
9 bnb_4bit_quant_type='nf4',
10 bnb_4bit_use_double_quant=True,
11 bnb_4bit_compute_dtype=getattr(torch, TORCH_DTYPE)
12)
13
14tokenizer = AutoTokenizer.from_pretrained('wanadzhar913/malaysian-mistral-llmasajudge-v2')
15model = AutoModelForCausalLM.from_pretrained(
16 'wanadzhar913/malaysian-mistral-llmasajudge-v2',
17 use_flash_attention_2 = True,
18 quantization_config = nf4_config
19)
20
21pipe = pipeline(
22 "text-generation",
23 tokenizer = tokenizer,
24 model=model,
25 device=0,
26)
27
28# create a prompt template
29prompt = """Anda adalah pakar dalam mengesan ketidakkonsistenan fakta dan halusinasi. Anda akan diberi satu dokumen dan satu soalan. Baca
30dokumen dan soalan/kenyataan yang diberikan dengan teliti dan kenal pasti Ketidakkonsistenan Fakta (iaitu mana-mana soalan/kenyataan yang
31tidak disokong atau bercanggah dengan maklumat dalam dokumen).
32
33### Anda perlu memilih antara dua pilihan berikut:
34- Tidak Konsisten dengan Fakta: Jika mana-mana soalan/kenyataan tidak disokong, terjawab atau bercanggah dengan dokumen, labelkannya sebagai 0.
35- Konsisten dengan Fakta: Jika semua soalan/kenyataan disokong/terjawab oleh dokumen, labelkannya sebagai 1.
36
37### Sebagai contoh:
38Dokumen: "Gajah adalah mamalia besar yang biasanya ditemui di Afrika dan Asia. Mereka hidup dalam kumpulan yang dikenali sebagai kawanan dan terkenal kerana mempunyai ingatan yang baik."
39
40Soalan/Kenyataan: "Gajah adalah mamalia besar yang biasanya ditemui di Eropah."
41Jawapan: {{'consistency': 0}}
42
43Soalan/Kenyataan: "Gajah adalah mamalia besar yang biasanya ditemui di Afrika dan Asia."
44Jawapan: {{'consistency': 1}}
45
46### Jawab berdasarkan dokumen dan soalan/kenyataan berikut:
47Dokumen: {passage}
48Soalan/Kenyataan: {question}
49
50Kembalikan pilihan konsistenan dalam format JSON untuk pilihan yang diberikan. Sebagai contoh: {{'consistency': 1}} atau {{'consistency': 0}}"""
51
52# https://www.thestar.com.my/business/business-news/2024/10/23/strong-support-for-chip-sector-under-budget-2025
53passage_english = """
54KUALA LUMPUR: Budget 2025 has set aside sizeable funds, both fiscal and non-fiscal, to ensure the success of the National Semiconductor Strategy (NSS), which is part of the New Industrial Master Plan 2030 (NIMP 2030), says Investment, Trade and Industry (Miti) Minister Tengku Datuk Seri Zafrul Abdul Aziz.
55
56Among the initiatives announced in the budget, he said were the RM1bil sovereign fund for the electrical and electronics sector and high-value activities as well as training funds allocated for several universities.
57
58Apart from that, he said there are initiatives to support mid-tier companies as well as tax incentives for companies in the industry.
59
60“I think we are on track (to achieve the target set in NIMP 2030). You have seen exports continue to grow in these sectors as well.
61
62“And if you look at the just-announced report card for our NIMP 2030, we should see positive growth by year-end, and growth in the manufacturing sector has contributed close to a 5% increase to our gross domestic product this year,” he said this during an interview with CNBC Asia Squawk Box yesterday.
63
64Tengku Zafrul was commenting on the progress of the NSS and NIMP.
65
66When asked how the new tax would help finance the bigger budget of RM421bil, he said that apart from the tax on dividends as well as the larger scope of sales and service tax, emphasis is given on cost discipline, for instance, via the merging of several agencies under Miti.
67
68“Yes, I am quite confident that we will meet the budget estimate. We have been meeting our deficit target, for example, and I think we will hopefully achieve it (fiscal target) in 2024,” he said.
69
70The ministry will also continue with initiatives to drive trade and investments to spur the country’s growth, added Tengku Zafrul. — Bernama"""
71
72question_english = "Zafrul will not meet the budget deficit."
73
74pipe(
75 prompt.format(passage=passage_english, question=question_english),
76 max_new_tokens = 8,
77 return_full_text=False,
78 temperature = 0.1,
79 do_sample = True,
80 top_p = 0.97,
81 top_k = 50,
82)[0]['generated_text']
83
84# you'll probably have to use some regex to parse the outputs
85>>> {"consistency": 0}