File size: 1,594 Bytes
82a6e1f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
---
license: apache-2.0
language:
- ar
base_model:
- iko-01/marocAI
pipeline_tag: text-generation
library_name: transformers
tags:
- maroc
- AI
- learn
---



HOW TO USE IT :
```python
TEST_PROMPTS = [
    "اشنو هو الذكاء الاصطناعي (AI) بصفة عامة؟",
    # U CAN ADD MORE Q in darija moroccain !

def generate_answer(prompt, max_new_tokens=150):
    full_prompt = f"Question: {prompt}\nAnswer:\n"
    out = pipe(full_prompt, max_new_tokens=max_new_tokens, do_sample=False)[0]['generated_text']
    if out.startswith(full_prompt):
        generated = out[len(full_prompt):]
    else:
        generated = out.split('Answer:')[-1]
    if '\n\n' in generated:
        generated = generated.split('\n\n')[0].strip()
    return generated.strip()

results = {p: generate_answer(p) for p in TEST_PROMPTS}

html_blocks = []
for q,a in results.items():
    html_blocks.append(f"<h3>Question:</h3><p>{q}</p><h3>Answer:</h3><p class='ans'>{a.replace('\n','<br/>')}</p><hr/>")

html = """
<div>
<button onclick="var els=document.getElementsByClassName('ans'); for(var i=0;i<els.length;i++){els[i].style.fontSize=(parseInt(window.getComputedStyle(els[i]).fontSize)+4)+'px'}">A+ (increase)</button>
<button onclick="var els=document.getElementsByClassName('ans'); for(var i=0;i<els.length;i++){els[i].style.fontSize=(parseInt(window.getComputedStyle(els[i]).fontSize)-4)+'px'}">A- (decrease)</button>
<div style='margin-top:10px'>{content}</div>
</div>
""".replace('{content}', ''.join(html_blocks))
print(html)
```

- this is bad model witch Eval loss: 1.7146, Perplexity: 5.55