T E L K O M NIKA   T elec o mm un ica t io n Co m pu t i ng   E lect ro nics   a nd   Co ntr o l   Vo l.  23 ,   No .   6 Dec em b er   20 25 ,   p p .   1 4 9 5 ~1 505   I SS N:  1 6 9 3 - 6 9 3 0 ,   DOI : 1 0 . 1 2 9 2 8 / T E L KOM NI K A . v 2 3 i 6 . 27400          1495     J o ur na l ho m ep a g e h ttp : //jo u r n a l.u a d . a c. id /in d ex . p h p /TELK OM N I K A   Retr iev a l - a ug m en ted  g enera tion for  Arabic leg a l in for m a tion t he f a m ily   co de c a se study       J a m a l H ri m ec h,  M o ha m m e d M g ha ri,   Yo us s ef   Z a z   D e p a r t me n t   o f   C o mp u t e r   S c i e n c e ,   F a c u l t y   o f   S c i e n c e ,   A b d e l mal e k   Essa â d i   U n i v e r si t y ,   T e t o u a n M o r o c c o       Art icle  I nfo     AB ST RA C T     A r ticle  his to r y:   R ec eiv ed   J u l   15 2025   R ev i s ed   Sep   19 2 0 2 5   A cc ep ted   Oct   19 2 0 2 5       T h is  d o c u m e n d e sc rib e t h e   im p lem e n tatio n   a n d   e v a lu a ti o n   o f   a   re tri e v a l - a u g m e n ted   g e n e ra ti o n   (RAG s y s tem   to   im p ro v e   a c c e s to   a n d   u n d e rsta n d in g   o f   M o ro c c a n   law ,   p a rt icu larly   t h e   f a m il y   c o d e   in   A ra b ic.  T h e   re se a rc h   a d d re ss e th e   d ra w b a c k o f   th e   w id e l y   u s e d   li n g u isti c   m o d e a p p li e d   to   c o m p lex   l e g a ter m in o lo g y   in   A ra b ic  a n d   a im to   h e lp   c it ize n a c c e ss   c ru c ial  leg a d a ta.  We  b u il a   n e w   c u sto m   d a tas e w it h   2 . 5   k   q u e sti on - a n sw e p a irs  w h il e   p re p ro c e ss in g   a n d   u sin g   th e   BG E - m 3   e m b e d d in g   m o d e in   t h is   e x p e ri m e n t.   P e rf o rm a n c e   m e tri c s,  su c h   a m e a n   re c ip ro c a ra n k   ( M RR ) Re c a ll @k ,   a n d   F 1 - sc o re ,   in d ic a te  th a th e   RAG   a p p ro a c h   is  e ffe c ti v e   c o m p a re d   to   th e   u se   o f   sta n d a lo n e   larg e   lan g u a g e   m o d e l s   ( LL M s ) .   M o re o v e r,   a n   e v a lu a ti o n   o n   m e tri c su c h   a th e   b lu e   s c o re ,   f id e li ty ,   re sp o n se   re lev a n c e ,   a n d   c o n tex tu a re lev a n c e   in d ica ted   th a th e   m a tch in g   o f   m e a n in g a n d   c o n tex t   w e r e   we ll   c a p tu re d ,   w h ich   sig n if ies   a   v e r y   g o o d   se m a n ti c   u n d e rst a n d i n g .   T h e   re se a rc h   h ig h li g h ts  th e   n e e d   f o lan g u a g e - sp e c if ic  m o d e sp e c ializa ti o n   i n   A ra b ic  a n d   p re se n ts   it m a in   c h a ll e n g e s,  su c h   a d iale c tal  v a riatio n s   a n d   a p p ro p riate   e v a lu a ti o n   m e a su re s.  T h e   re su lt s   in d ica te  t h a w e ll - d e v e lo p e d   RAG   s y ste m o ff e a   p ro m isin g   a p p ro a c h   to   im p ro v in g   a c c e s to   leg a l   in f o rm a ti o n   in   A ra b ic - sp e a k in g   p ra c ti c e   c o m m u n it ies   a n d   to   g u i d in g   f u tu re   re se a rc h   a n d   d e v e lo p m e n in   t h is  f ield .   K ey w o r d s :   A r ab ic - n at u r al  la n g u a g p r o ce s s in g   L ar g la n g u a g m o d el   L e g al  ac ce s s ib ilit y   Mo r o cc an   la w   R etr iev al - a u g m e n ted   g e n er ati o n   Se m a n tic  s ea r c h   T h is i a n   o p e n   a c c e ss   a rticle   u n d e r th e   CC B Y - SA   li c e n se .     C o r r e s p o nd ing   A uth o r :   J am al  Hr i m ec h   Dep ar t m en o f   C o m p u ter   Scie n ce Facu l t y   o f   Scie n ce ,   A b d el m ale k   E s s d i U n i v er s it y   P . O.   B o x .   2 1 2 1 ,   M Han n ec h   I I ,   T etu an ,   9 3 0 3 0 ,   Mo r o cc o     E m ail:  j a m al. h r i m ec h @ et u . u a e. ac . m a       1.   I NT RO D UCT I O   R etr iev al - a u g m e n ted   g e n er ati o n   ( R AG)   r ep r esen ts   o n s u c h   p o w er f u an d   cr ea tiv r esp o n s to   th li m ita tio n s   lar g p r e - tr ain ed   lan g u a g m o d els  s u f f er   f r o m   w h e n   ap p lied   to   k n o w led g e - r i ch   n at u r al  lan g u a g e   p r o ce s s in g   ( NL P )   tas k s .   Alt h o u g h   t h ese   m o d els   h a v s h o w n   r e m ar k ab le  ab ilit y   to   m e m o r i ze   f ac ts ,   th e y   o f ten   h av d i f f icu lt y   p r ec is el y   q u er y in g   t h at  s a m k n o w led g e ,   wh ich   m a n i f est s   as  h all u ci n ati o n s   ( th g e n er atio n   o f   f alse,  u n s u p p o r ted   f ac ts )   a n d   o p ac ity   in   th eir   d ec is io n - m ak in g .   T h R A m o d els  ad d r ess   th i s   p r o b lem   b y   co m b i n i n g   p ar a m etr ic  an d   n o n - p ar a m etr ic  m e m o r y   s y s te m s .   I n   p ar ticu lar ,   R A is   t h co m p o s itio n   o f   p r e - tr ain ed   g en er ati v m o d el  ( p ar a m etr ic  m e m o r y )   an d   r etr ie v ab le  k n o w led g b ase,   w h ic h   is   u s u all y   d en s e   v ec to r   in d ex   o f   d o cu m e n t s   ( n o n - p ar a m etr ic  m e m o r y ) .   S u c h   h y b r id   m ec h a n is m   e n ab les  m o d els  to   d y n a m icall y   r etr iev an d   u tili ze   k n o w l ed g e   f r o m   th e x ter n al  s o u r ce   w h il g en er ati n g   te x t,  w h ich   ca n   m ak t h g e n er ated   r esp o n s m o r f ac t u al,   r elate d   an d   v ar ied .   T h is   h a s   f e i m p o r tan t   ad v a n tag e s le s s   h allu ci n atio n ,   b etter   p er f o r m a n ce   o n   v ar iet y   o f   NL P   tas k s ,   ea s ier   w o r ld   k n o w led g u p d at es  b y   r ep laci n g   th n o n - p ar a m etr ic  m e m o r y   i n d ex ,   an d   m o r in ter p r etab ilit y   b ec au s e   w ar p u ll in g   u p   h u m a n - r ea d ab le  d o cu m en ts .   As  b en e f it,   R A h a s   m u ch   f e w er   tr ain ab l p ar am eter s   t h an   t h lar g p ar a m etr ic - o n l y   m o d els an d   ac h i ev es  m o r ef f ec ti v e   p er f o r m a n ce  [ 1 ] A d d it i o n a lly ,   R A G   c an   s ig n if i c an t ly   r e d u c g r a p h i cs   p r o c e s s in g   u n it   ( G PU )   a n d   r an d o m   a cc e s s   Evaluation Warning : The document was created with Spire.PDF for Python.
                      I SS N :   1 6 9 3 - 6930   T E L KOM NI K A   T elec o m m u n   C o m p u t E C o n tr o l ,   Vo l.  23 ,   No .   6 Dec em b er   20 25 1 4 9 5 - 1 505   1496   m em o r y   ( R A M )   c o s ts   w h e n   o u ts o u r c in g   k n o w l e d g e   t o   s ca l ab l e   d a t a   s t o r es   ( as   o p p o s e d   t o   m o d e l   w e ig h ts ) ,   an d   r o b u s t   s c a lin g   la w   an d   em p i r i ca l   r e s u l ts   s u g g es t   th a t   s m a ll e r   m o d e ls   w it h   la r g e   r e t r i ev a l   i n d i c e s   a r e   c o m p e ti t iv w ith   o r   ev en   o u t p e r f o r m   la r g e r   f u l ly   p a r am et r i c   m o d e ls   a t   a   f r ac t i o n   o f   t h e   G PU   m em o r y   c o s t   [ 2 ] .   Fu r t h er m o r e,   th R A s y s te m   ca n   ac ce s s   an d   in te g r ate  r elate d   in f o r m atio n   in   s tr u ct u r ed   d ata,   d o cu m en ts   o r   d atab ases ,   s o   t h at  th i n f o r m atio n   is   n o o n l y   s u itab le  f o r   th p r e - s ett in g   co n tex o f   t h m o d el,   an d   th d ata  s o u r ce   ca n   b r ep lace d   f lex ib l y   ac co r d in g   to   th e   ac tu al  n ee d   f o r   th co n v er s io n   o f   t h k n o w led g e   o f   th lar g lan g u ag m o d el  ( L L M )   to   s p ec if ic  k n o w led g e   d o m ai n .   Fro m   R A s tr u ct u r p er s p ec tiv e,   t h er e   ar t w o   f u n d a m en tal  co m p o n en t s .   First,  t h r etr iev er   is   th p r o ce s s   o f   f i n d in g   an d   ex tr ac tin g   r elev a n t   in f o r m atio n   f r o m   lar g d atas et  o r   k n o w led g b ase  b y   co m p ar in g   t h q u e s tio n   v ec to r   an d   d ata  v ec to r s   to   f i n d   th clo s est  o n es  i n   ter m s   o f   m ea n in g .   I n   o r d er   to   tr a n s f o r m   t h d ata  in to   v ec to r ,   a   p r elim i n ar y   p r o ce s s   ca lled   in d ex i n g   is   m a n d ato r y   f o r   s to r in g   t h d ata  in   v ec to r   d atab ase.   T h is   s er v e s   to   o p tim ize  th s ea r ch   f u n ctio n alit y   s o   th at  r etr ie v al  is   a s   f ast  a n d   e f f icien as  p o s s ib le.   Seco n d ,   th g en er ato r   is   u s u all y   t h L L th at  le v er ag e s   t h in f o r m atio n   r etr ie v ed   b y   th r e tr iev er   an d   q u er y   to   g e n er ate  a   co h er en t a n d   f ac tu al  a n s w er   [ 3 ] .   Giv e n   th ab ilit y   o f   R A s y s te m s   i n   i m p r o v i n g   th ac cu r a c y   o f   L L M s ,   th e y   h av b ee n   ap p lied   in   v ar io u s   f ield s ,   s u c h   as  th b an k i n g   s ec to r ,   R A s y s te m   n a m ed   U n i Ask   i n ten d ed   f o r   E u r o p ea n   b an k   e m p lo y ee s   ac ce s s in g   d o cu m e n tatio n   r elate d   to   p o licies,  r eg u la ti o n s   an d   p r o ce s s e s   [ 4 ] .   I n   th e   h ea l th   a n d   m ed icin e   s ec to r ,   i n   p ar ticu lar   f o r   t h p u r p o s o f   in ter p r etin g   r ec o m m en d a tio n s ,   a s s i s ti n g   w it h   d ia g n o s i s ,   s elec ti n g   elig ib ilit y   f o r   clin ic al  tr ials ,   s ea r ch i n g   f o r   clin ic al  in f o r m at io n   a n d   ex tr ac tin g   in f o r m atio n   f r o m   s cien t if ic  liter at u r [ 5 ] .   I n   th f i n an cia s ec to r ,   R A p ip elin h as  b ee n   d ev elo p ed   f o r   c o m p ar ati v s t u d y   o f   r etr iev al  an d   p r o m p ti n g   s tr at eg ies  i n   f i n a n cial  q u ali t y   as s u r an ce   tas k s ,   i n f o r m i n g   p r o d u ctio n   d ep lo y m en t   r ec o m m e n d atio n s ,   alt h o u g h   th m ain   f o cu s   is   o n   t h an al y s i s   o f   co n tr o lled   co m p o n e n t s   [ 6 ] .   I n   th leg al  f ield ,   an   i m p le m e n tatio n   o f   t h R A s y s te m   to   ass i s co n te n cr e ato r s   in   d is p u te s   r elate d   to   th e   f air   u s d o ctr in in   Am er ica n   co p y r ig h la w ,   w h i ch   co m b i n es  s ev er al  e le m e n t s   ( s e m a n tic  s ea r ch ,   j u d icial  cit atio n   n e t w o r k s ,   a n d   leg al  k n o w led g g r ap h s ) ,   th is   w o r k   i m p r o v es  t h leg al  r ele v an ce   o f   th d o cu m e n ts   f o u n d ,   w h ic h   is   cr u cial  f o r   s o lid   f air   u s d e f en s [ 7 ] .   I n   th is   p ap er   w w il i m p le m e n R A s y s te m   i n   t h Mo r o cc an   le g al  co n tex t,  p ar tic u lar l y   th f a m il y   co d e,   w h ic h   w ill  f ac ilit ate  cit i ze n s   u n d er s ta n d in g   o f   t h la w .   W w ill  u s m u lt ili n g u al  e m b ed d in g   m o d els   ( o p en   s o u r ce )   p r o v in g   th e ir   p er f o r m an ce   i n   t h A r ab ic  lan g u ag f o r   th r ec o v er y   o f   r elev a n t d o cu m e n t s ,   an d   lar g lan g u a g m o d el  as  g e n er ato r .   T h o b j ec tiv o f   th is   wo r k   is   p ar o f   th r ig h o f   a cc es s   to   in f o r m a tio n   an d   th s i m p li f icat io n   o f   j u d icial  p r o ce d u r es a n d   p r o ce s s es.  De s p ite  its   p r o v e n   s u cc es s ,   R AG  h as  y et   to   b ap p lied   to   th m o r p h o   s y n tactic  a n d   s e m an tic  in tr icac ie s   o f   A r ab ic  leg al  lan g u ag e.   C h alle n g es  i n c lu d h a n d lin g   l eg a l   ter m i n o lo g y ,   m ai n tai n i n g   th co n ten v alid it y   o f   leg a l c lau s es r ep r o d u ce d   f r o m   r etr ie v al  s y s te m s ,   a n d   cr ea ti n g   r eliab le  ev al u atio n   s ets,   as w e l as  t h s ca r cit y   o f   a n n o tated   A r ab ic  le g al  co r p o r a.   T o   f ill  t h is   lac u n a,   th i s   p ap er   ai m s   to   an s w er   t h f o ll o w i n g   r esear ch   q u e s tio n s w h at  i s   th b est  w a y   to   ch u n k   le g al   d ata  in   w a y   t h at   ac k n o w led g es  s e m a n tic  r ep r es en tatio n s ?   d o   s tan d ar d ized   m et r ics  p r o p er ly   m ea s u r t h q u ali t y   o f   t h g e n er ated   leg ald o cu m en ts   i n   A r ab ic?   an d   w h ic h   o p en - s o u r ce   m u l tili n g u al  e m b ed d in g   m o d el  ac h ie v e s   t h b est   p er f o r m a n ce   f o r   th r etr iev al  o f   th r ele v an t a r ticles o f   t h f a m il y   co d e?     T o   ad d r ess   th ese   q u es tio n s ,   t h e   k e y   co n tr ib u tio n s   o f   t h i s   p ap er   ar as  f o llo w s t o   th at   en d ,   w co m p ile   n e w   co r p u s   o f   2 , 5 0 0   ar ab ic  q u esti o n - a n s w er   p air s   f o c u s ed   o n   t h Mo r o cc an   f a m il y   c o d e,   o b tain ed   b y   s e m i - au to m at ic  p ip elin a n d   m an u a ll y   c h ec k ed .   T h s tr u ct u r o f   t h is   d ata s et,   w h ic h   i n clu d es   th q u esti o n ,   s o u r ce ,   an d   r ef er en ce   a n s w er ,   is   ill u s tr ated   in   Fig u r 1 .           F ig u r e   1 .   D a t as e t   s t r u ct u r e   Evaluation Warning : The document was created with Spire.PDF for Python.
T E L KO MN I K A   T elec o m m u n   C o m p u t E C o n tr o l           R etri ev a l - a u g men ted   g en era ti o n   fo r   A r a b ic  leg a l in fo r ma tio n :   t h fa mily  co d ca s s tu d ( Ja ma l H r imec h )   1497   W p r o p o s clau s e - b ased   d o cu m e n d iv is io n   ap p r o ac h   th at  is   m o r s e m a n tica ll y   r elev a n th a n   th e   s tan d ar d   ch a r ac ter   o r   to k en - b a s ed   ap p r o ac h   f o r   leg al  te x ts .   W p r esen co m p ar ativ a n a l y s i s   o f   s tate - of - t h e - ar m u lt ilin g u al  e m b ed d in g   m o d els  o n   leg al  r etr iev al  f o r   th A r ab ic  lan g u a g an d   d is cu s s io n   o f   ev a lu at io n   m etr ics  w i th   f o cu s   o n   th c h al len g e s   o f   t h A r ab ic   leg al   d o m ai n .   T h r est  o f   th is   p ap er   f o llo ws  p atter n s ec tio n   2   d i s cu s s es  r elate d   w o r k .   Sectio n   3   ad o p ts   th e   m et h o d o lo g y   u s ed   i n   t h i s   p a p er .   Sectio n   4   p r esen t s   t h e x p er i m e n ts   an d   e x p lai n s   t h r esu lt s .   Sectio n   5   s u m m ar izes t h co n cl u s io n s   a n d   k e y   id ea s ,   as  w ell  as  s u g g e s tio n s   th at  f u tu r r esear c h er s   c o u ld   f o llo w .       2.   RE L AT E WO RK   R ec en t   y ea r s   h a v s ee n   t h e m er g e n ce   o f   r esear ch   ap p l y in g   au g m e n ted   r etr iev al - g en er at io n   ( A R G )   ar ch itect u r es   s y s te m s   t h at  co m b in e   n e u r al  r etr ie v al  o n   s e m an tic  e m b ed d in g s   w i th   lar g lan g u a g m o d el  tex t   g en er atio n   f o r   A r ab ic  lan g u a g task s .   El - B elta g y   a n d   A b d all ah   [ 8 ]   p r esen co m p r eh e n s i v ca s s tu d y   o n   th e   i m p le m en ta tio n   a n d   e v al u atio n   o f   R AG  f o r   A r ab ic  tex ts .   T h eir   w o r k   ex p lo r es  t h p er f o r m an ce   o f   d if f er en t   s e m a n tic  e m b ed d in g   m o d els ( a m o n g   th e m   m u lt ili n g u al  m o d els lik A r aB er t a n d   C o h er 1 )   f o r   r etr iev al,   an d   a   f e w   lo n g - ter m   tr an s latio n   L L m o d els  f o r   g en er at io n .   T h is   w o r k   al s o   in v e s ti g ates  t h d i f f ic u lties   o f   d ialec tal   v ar iatio n s   b et w ee n   d o cu m e n ts   a n d   q u er ies,  an d   s h o w s   th at  d esp ite  th ch alle n g es,  it  w as  p o s s ib le  to   co m p o s e   R A p ip elin f o r   A r ab ic  b y   f u s i n g   ex i s ti n g   s e m a n tic  e m b ed d in g s ,   a n d   L L Ms.  A b d elaz i m   et  a l.   [ 9 ]   t h tea m   co n ce n tr ated   o n   t h co r g en er atio n   p ar o f   A r ab ic  R A s y s te m s ,   a n d   co m p ar ed   ten   s ta te - of - th e - ar t   m u ltil i n g u al   s e m a n tic   e m b e d d in g   m o d els  to   j u d g a v ailab le  A r ab ic  s ea r ch - g e n er atio n   o u tp u ts   a n d   p er f o r m a n ce .   On   th A r ab ic  r ea d in g   co m p r eh e n s io n   d ataset   ( AR C D )   test b ed ,   th e y   r ep o r ted   th at  th Mic r o s o f t   E 5 s en ten ce   e m b ed d in g   m o d el   ac h iev ed   t h h i g h est  r ec all  r a te  o f   1 0 ,   w ith   ab o v 9 0 %.  T h is   w o r k   e m p h asize s   th n ec e s s it y   o f   u s i n g   A r ab ic - ap p r o p r iate  m u ltil in g u al  w o r d   e m b ed d in g s   f o r   A r ab ic  s ea r ch   tas k s .   A l s h a m m ar y   et  a l.  [ 1 0 ]   t h ey   in tr o d u ce   t h r etr iev al  f ac t - c h ec k i n g   p r o m p g en er atio n   ( R FP G )   f r a m e w o r k ,   f ac t - a w ar R A G   ap p r o ac h   to   q u esti o n   an s w er i n g   i n   A r ab ic,   a   lo w - r e s o u r ce   l an g u a g e.   T h f ac t - ch ec k i n g   is   p er f o r m ed   in   an   a s y m m etr ic  m u lt i - s ta g p ip elin r etr iev al  s et u p   an d   th g en er atio n   is   co n d itio n ed   o n   p er s o n alize d   p r o m p ts .   T h R FP m o d el  d e m o n s tr ated   h ig h   ac c u r ac y   ( 1 0 0 %)  in   an s w er in g   1 2 3   A r ab ic   q u esti o n s ,   as  w ell  as  s o u r ce   citatio n   ac cu r ac y   o f   9 8 %,  o u tp er f o r m in g   t h s tan d ar d   R AG  an d   r ec en L L Ms   s u c h   as  GP T - 4   an d   GPT - 4 o   i n   th eir   e x p er i m e n ts .   Ho w e v er ,   th s co p o f   th eir   ev al u atio n   w as  li m ited   to   a   co n tr o lled   q u esti o n   s e t r ath er   t h an   o p en   o r   leg al  co r p o r a.   C u r r e n tl y   r esear ch   t h at  tar g e ts   R A in   t h leg al  f ie ld   in v o lv e s   m o s tl y   r etr ie v al  r ath e r   th an   f u ll   g en er atio n   p ip elin e s .   J af ar   et  a l.   [ 1 1 ]   p r esen n e w   ap p r o ac h   to   au to m ate  r etr ie v al  o f   A r a b ic  leg al  te x ts   u s in g   u n s u p er v is ed   to p ic  m o d eli n g   ( T o p 2 Vec )   an d   d en s it y - b ased   clu s te r i n g   ( HDB S C A N) .   T h au th o r s   ad d r ess   t h m o r p h o lo g ical  co m p lex it y   a n d   a m b ig u it y   o f   A r ab ic  leg al  tex t s   th r o u g h   p r ep r o ce s s i n g   s tep s   s u c h   as   n o r m aliza t io n   a n d   to k e n izatio n .   B u t   th e ir   s y s te m   w h i le  ac h iev in g   a   d o cu m e n t   r etr iev al  r ate  o f   8 7 a n d   a   co v er ag r ate  f o r   8 0 %,  lack s   t h g e n er ati v ca p ab ilit y   n ee d e d   f o r   f u ll  R A G.     S e v e r a l   m o r e   g e n e r a l   l e g a l   t e c h n o l o g y   s t u d i e s   h a v e   i n v e s t i g a t e d   o r   p r o p o s e d   R AG   p i p e l i n e s   f o r   l e g a l   t e x t s ,   b u t   g e n e r a l l y   n o t   f o c u s e d   o n   Ar a b i c .   F o r   e x a m p l e ,   H i n d i   e t   a l.   [ 1 2 ]   p r o v i d e   a   s y s t e m a t i c   s u r v e y   o f   e x i s t i n g   R AG   a r c h i t e c t u r e s   i n   t h e   l e g a l   d o m a i n ,   d i s c u s s i n g   r e t r i e v a l   m e t h o d s ,   e v a l u a t i o n   m e t r i c s ,   a n d   e t h i c a l   c o n s i d er a t io n s ,   b u t d o   n o t   r ep o r t d i r e c t e x p e r i m e n t s   o n   Ar a b i l e g a l   c o r p o r a .   W a h i d u r   e a l .   [ 1 3 ]   a n d   K a l r a   e t   a l .   [ 1 4 ]   i n t r o d u c R A G   f r a m e w o r k s   t a i l o r ed   to   t h e   le g a l   d o m a i n ,   w i t h   i n n o v a t i o n s   s u c h   a s   r e c u r s i v f e e d b a c k   o r   a d a p t i v e   h y b r i d   r e t r i e v a l ,   b u t   t h e i r   w o r k   d o e s   n o t   f o c u s   o n   Ar a b i c   o r   u s e   p r i m a r y   Ar a b i c   l e g a l   d o c u m e n t s .   Giv e n   t h lac k   o f   p r ev io u s   s tu d ies  o n   t h ap p licatio n   o f   R AG  s y s te m s   in   t h f ield   o f   Mo r o cc an   la w ,   a   d ir ec co m p ar is o n   is   h ar d l y   p o s s ib le.   Ho w e v er ,   w ca n   p u o u r   r esu lt s   in   t h b r o ad er   co n te x o f   leg al  ar ti f icial   in telli g e n ce   ( AI )   r esear ch .   F o r   ex a m p le,   w o r k   o n   th le g al  g en er al  la n g u a g u n d er s tan d in g   e v al u atio n   ( L ex GL UE )   b en ch m ar k   h as  a lr ea d y   n o ted   th co m p lex i t y   o f   E n g lis h   leg al  la n g u a g f o r   s tan d ar d   lan g u a g m o d el s   [ 1 5 ] .   On   th o th er   h an d ,   th cr ea tio n   o f   s p ec ialized   q u esti o n - a n s w er in g   co r p o r f r o m   co m p le x   E u r o p ea n   r eg u lat io n s   s u c h   as  th e   g e n er al  d ata  p r o tectio n   r e g u la tio n   ( GDP R )   [ 1 6 ] ,   is   co n s id er ed   an   im p o r tan t   s tep   f o r   th d e v elo p m en o f   r eliab le  q u esti o n   a n d   an s w er i n g   ( Q &A )   s y s te m s .   O u r   ap p r o ac h   is   i n   li n w it h   s y s te m s   s u ch   as  C h at L a w   [ 1 7 ]   fo r   C h in ese  la w .   Un s u r p r is in g l y ,   C h at L a w   also   co n f ir m s   th n ee d   to   in teg r ate  ex ter n al   k n o w led g e   to   r ed u ce   f ac t u al  er r o r s   m ad b y   L L M s   i n   C h i n a.   Fin a ll y ,   th e   p er f o r m a n ce   o f   o u r   r esear c h   m o d el s   ca n   b co m p ar ed   to   th r ep o r ts   o f   p r ev io u s   lar g in f o r m at io n   r etr i ev al  te s t s   id en ti f ied .   T h is   d em o n s tr ate s   th r o b u s tn e s s   o f   th e s m o d els e v e n   w h e n   ap p lied   to   f ield   as sp ec ialized   as   la w .   T o   p r o v id clea r   co m p ar is o n   w i th   p r io r   ar t,  T a b le  1   s u m m a r izes  th m o s r ele v an s t u d ies d is cu s s ed   in   t h p r ev io u s   s ec tio n .   T h is   T ab le   1   h ig h lig h t s   th k e y   d i f f e r en ce s   i n   d ataset  s ize,   la n g u a g f o cu s ,   e v al u atio n   m etr ics,  a n d   tec h n ical  li m ita ti o n s ,   t h er eb y   p o s itio n in g   o u r   c o n tr ib u tio n   w it h i n   t h e x is t in g   lan d s ca p o f   le g al  A I   r esear ch .       Evaluation Warning : The document was created with Spire.PDF for Python.
                      I SS N :   1 6 9 3 - 6930   T E L KOM NI K A   T elec o m m u n   C o m p u t E C o n tr o l ,   Vo l.  23 ,   No .   6 Dec em b er   20 25 1 4 9 5 - 1 505   1498   T ab le  1 C o m p ar ativ r es u lt s   o f   s u m m ar izi n g   p r e v io u s   w o r k   A sp e c t   L e x G L U ( C h a l k i d i e t   a l .   [ 1 5 ] )   P r i v a t e   I n t e r n a t i o n a l   L a w   ( P I L )   d a t a se t   ( S o v r a n o   e t   a l .   [ 1 6 ] )   C h a t L a w   ( C u i   e t   a l .   [ 1 7 ] )   D a t a se t   s i z e   d a t a se t s,   2 0 0   K +   t o t a l   i n st a n c e s   1 7   q u e st i o n s ( 9   n e w   +   8   f r o m p r e v i o u s w o r k )   4   M   s a mp l e s a c r o ss  1 0   m a j o r   c a t e g o r i e s   L a n g u a g e   En g l i sh   o n l y   En g l i sh   ( EU   r e g u l a t i o n s)   C h i n e se   l e g a l   t e x t s   D o mai n   c o v e r a g e   M u l t i p l e :   Eu r o p e a n   C o n v e n t i o n   o n   H u ma n   R i g h t s (E C H R ) ,   U S   l a w ,   EU   l a w ,   c o n t r a c t s   P I L   o n l y   B r o a d   l e g a l   d o ma i n s   Ev a l u a t i o n   me t r i c s   M i c r o / mac r o   F 1 ,   mu l t i p l e   t a sk - s p e c i f i c   me t r i c s   T o p 5 - r e c a l l ,   T o p 5 - p r e c i si o n ,   T o p 5 - F1   A c c u r a c y ,   F 1 ,   e x p e r t   e v a l u a t i o n   ( 4   d i me n s i o n s:   c o m p l e t e n e ss,  c o r r e c t n e ss,  g u i d a n c e ,   a n d   a u t h o r i t y )   B e n c h mar k u se d   7   s t a n d a r d i z e d   l e g a l   t a sk s (E C H R ,   S u p r e me   C o u r t   o f   t h e   U n i t e d   S t a t e s (S C O T U S ) ,   a n d   Eu r o p e a n   U n i o n   L a w   A c c e ss Po r t a l   ( EU R - L E X ) )   C u s t o m PI L   q u e st i o n s   w i t h   e x p e r t   v a l i d a t i o n   L a w B e n c h ,   l e g a l   p r o f e ssi o n a l   e x a m   H u ma n   e v a l u a t i o n   L i mi t e d   h u ma n   e v a l u a t i o n   b a se l i n e   I n d e p e n d e n t   l e g a l   e x p e r t   v a l i d a t i o n   L e g a l   e x p e r t   a sse ssm e n t   o n   r e a l   c a se s   P e r f o r man c e   r e su l t s   T a sk - d e p e n d e n t :   5 0 - 9 5 F 1   3 8 . 0 5 %   T o p 5 - F 1   o v e r a l l   6 0 . 0 8 %   a v g   o n   L a w B e n c h   ( v s G P T - 4 :   5 2 . 3 5 %)   G e o g r a p h i c   sco p e   U S / EU - f o c u se d   l e g a l   sy st e ms   EU - fo c u se d   ( P I L )   C h i n a - f o c u se d   l e g a l   s y st e m   L a n g u a g e   l i mi t a t i o n s   En g l i sh   o n l y   En g l i sh   o n l y   C h i n e se   p r i maril y   T e c h n i c a l   l i mi t a t i o n s   M i ss i n g   h u ma n   b a se l i n e s,   c o p y r i g h t   r e st r i c t i o n s   L o w   b a se l i n e   p e r f o r man c e ,   r e q u i r e mu l t i - h o p   r e a so n i n g   P r i v a c y   c o n c e r n s,  h a l l u c i n a t i o n   r i s k d e sp i t e   mi t i g a t i o n       3.   M E T H O D   T h is   w o r k   ai m s   to   ex p lo it  th R A ar ch itect u r in   t h Mo r o cc an   leg al  co n te x an d   to   th i s   en d   w w ill   ev alu a te  t h p er f o r m a n ce   o f   m u ltil i n g u al   e m b ed d in g   m o d e ls   ( o p en   w ei g h ts )   i n   th e   A r ab ic  leg al   co n te x t,  i n   p ar ticu l ar   f a m il y   co d ter m i n o lo g y   as  w ell  as  th e v al u ati o n   o f   t h ca p ac it y   o f   lar g m u ltil i n g u a lan g u ag e   m o d el s   f o r   g en er ati n g   co m p let an d   p r ec is r esp o n s es.   T h m et h o d   ad o p ted   in   th is   p ap er   is   as  f o llo w s s tar tin g   w it h   th ex p er i m en tatio n   o f   m u ltil i n g u a e m b e d d in g   m o d els   in   th leg al  co n tex in   A r ab ic   lan g u ag e,   th e n   th e   ex p er i m e n tati o n   o f   lar g lan g u ag m o d el s   b ased   o n   o n o f   th e m b ed d in g   m o d els p r o v in g   its   h ig h   q u alit y   an d   s p ee d   r atio .     3 . 1 .     Da t a s et   I n   th i s   s u b s ec tio n ,   w ex p lo r th d ataset  g en er at io n   m e th o d   u s ed   in   t h is   w o r k   a s   w ell  a s   it s   p r ep r o ce s s in g .   T h d ataset  u s ed   in   th i s   w o r k   co n tai n s   2 . 5   k   q u est io n s   a n d   an s w er s   o n   Mo r o cc an   la w   w a s   d esig n ed   to   ev al u ate  o u r   R AG  s y s te m   o n   t h A r ab ic  le g al  co n tex t.  I w a s   cr ea ted   w it h   t h as s is ta n ce   o f   r o b u s t   L L f o r   co n ten g en er atio n s ,   it  w a s   s tr u ctu r ed   w it h   th r ee   co lu m n s :   { q u e s tio n s },   {so u r ce an d   {r ef er en ce }.   {Qu est io n s } : q u esti o n s   as k ed   b y   t h u s er ;   {So u r ce }:  th d o cu m e n t r elati n g   to   t h q u est io n   as k ed   {Ref er e n ce }:  t h co r r ec t a n d   co m p lete  a n s w er   to   th q u est i o n s .   T h q u esti o n s   co lu m n   co n tai n s   all  p o s s ib le  q u esti o n s   f o r   ea ch   ar ti cle  in   t h A r ab ic  leg al  d o cu m en t.  T h ese  q u esti o n s   w er g en er ate d   u s in g   GE MI NI   2 . 5 ,   u s in g   w ell - d etailed   an d   s tr u ct u r ed   p r o m p A l g o r ith m   1 in   o r d er   to   o b tain   th m ax i m u m   n u m b er   o f   q u es tio n   m o d ali ties   th a an   i n d iv id u al  o r   leg al   ex p er co u ld   ask .   An s w er   g e n er atio n   w as p er f o r m ed   b y   an o t h er   L L ( GP T - 4 o )   u s in g   s p ec i f ic  p r o m p t   Alg o r ith m   2 ,   to   an s w er   q u esti o n s   g e n er ated   b y   GE MI NI   2 . 5 .   Div er s if y i n g   L L Ms  in   t h q u est io n a n s w er   g en er atio n   p r o ce d u r e   o v er co m es  th p r o b lem   o f   p r o p ag ated   er r o r s th at  is ,   if   an   L L m a k e s   an   er r o r   in   q u esti o n   ( a m b ig u it y ,   m is in ter p r etatio n ) ,   it  w ill  li k el y   b r ep ea ted   in   th an s w er .   H o w e v er ,   w co n ce d th at  g en er atin g   th d ata  u s in g   L L Ms   m a y   i n tr o d u ce   s o m b i as.  T h es b iases   ca n   r e v ea t h e m s el v es   as  a n   i n ter p r etiv b i as,  w h er t h m o d el   m a y   ex h ib it  p r ef er e n ce   f o r   d o m i n a n o r   m ai n s tr ea m   i n ter p r etatio n   o f   le g al  cla u s e i n   its   v as t h o u g h   u n co n tr o lled   tr ain i n g   d ata m is s in g   o u o n   k e y   s u b tle ties .   T h er is   f u r t h er   d an g er   o f   f r a m i n g   b ias;   th g e n er ated   q u esti o n s   m a y   s er v to   r ed u ce   co m p le x   leg a is s u es  to   v er y   s i m p le  f a u lt y   f o r m   o r   lead   to w ar d s   s o m p ar ticu lar   k in d   o f   a n s w er .   Of   co u r s e,   d i v er s i f y in g   L L Ms  in   q u esti o n - a n s w er   g e n e r atio n   ca n   lead   to   in co n s i s t en c y   i s s u es   s te m m i n g   f r o m   t h d if f er en a n al y s i s   an d   in ter p r etatio n   s t y l es  o f   ea ch   L L M,   w h ich   ca n   th u s   cr ea te  q u esti o n - an s w er   m is al ig n m en ts .   T o   ad d r ess   th i s   p o ten tial  f o r   b ias  an d   in co n s i s te n c y ,   w m an u all y   ch ec k   t h q u e s tio n s   an d   th eir   an s w er s .   T h is   d ataset   h as  b ee n   c h ec k ed   a n d   co r r ec t ed   b y   p r iv ate  la w   la u r ea tes,  all   th er r o r s   f o u n d   i n   th is   d ataset  ar g en er all y   r elate d   to   th s tr u ctu r in g   o f   th q u es t io n s ,   th an s w er s   an d   th s o u r ce   tex ( la w   clau s e) ,   Evaluation Warning : The document was created with Spire.PDF for Python.
T E L KO MN I K A   T elec o m m u n   C o m p u t E C o n tr o l           R etri ev a l - a u g men ted   g en era ti o n   fo r   A r a b ic  leg a l in fo r ma tio n :   t h fa mily  co d ca s s tu d ( Ja ma l H r imec h )   1499   in   p ar ticu lar   w f in d   s ev er al  an s w er s   g en er ated   in   w a y   t h at  is   to o   co n cise,  w h ic h   ca u s es  a m b i g u i t y   i n   th e   u n d er s ta n d in g   o f   th co n tex t,  t h u s   w f in d   d is o r d er   at  th le v el  o f   m ap p in g   b et w ee n   q u esti o n s   an d   it s   an s w er   an d   its   s o u r ce   tex t.     Algorithm 1. Prompt used to generate questions of  d ataset   yo ar an   ex pe rt   in   ar a b ic   la te xt fr om   th is   ar ti cl e   in   at ta ch ed   fi le s,   cr ea te   qu es ti on s   for any article with respecting the following instructions:   Output:    A TXT file with:   article_number: The article number (e.g 65).   questions: A list of question in Arabic:   Short articles ( 1 - 2 sentences): 1 questions   Lon ge ar ti cl es   (m ul ti pl e   se nt en ce s,   cl au se s,   or   p oi nt s) At   le as on e   qu es ti on   pe di st in ct   po in (e .g cl au se co nd i ti on ex ce pt io n,   st ep ),   w it mi ni mu of   qu es ti on an no   up pe r   limit.   Guidelines:    1.Article Analysis:      - Fo {s ho rt   ar ti cl es (1 - se nt e nc es ),   id en ti fy   th co re   id ea   an ge ne ra te   on question.     - Fo {l on ge ar ti cl es },   br ea th te xt   in to   di st in ct   po in ts   (e .g ea ch   cl au se condition,  exception,  or  procedural  step)  and  ge nerate  at  least  one  ques tion  per  point.  Examples of distinct points:     - A separate sentence or clause.     - Each numbered condition or requirement (e.g, 1), 2), 3)).     - Exceptions or special cases (e.g, if unable to speak).   1.Question Generation:      - {Short articles}: Generate exactly one question.     - {Longer articles}:  Generate at least one question  per distinct point ident ified. If  fe we th an   po in ts   ex is t,   pa wi th   ad di ti on al   qu es ti on to   re ac 5.   If   mo r th an   po in ts   exist, generate questions for all points, ensuring more than 5 questions.   Use var ied question types  (e.g, direct, yes/no, hypothetical).     Algorithm   2.  Prompt used to generate answers of  d ataset   yo ar an   ex pe rt   in   ar ab ic   la te xt fr om   th is   qu es ti on   in   at ta ch ed   fi le na me d,   ge ne ra te   concise  answer  for  the  que stions  from  the  law  text in   fi le   LAW   wi th   re sp ec t in th fo ll ow in instructions:   the answers should be arabic only;   ea ch   qu es ti on   as so ci at ed   wi th   it it em   nu mb er   an th an sw er   mu st   be   ge ne ra te fr om   th te xt   of the same item number in the law text file;   output format:   article _1:    answers:     1 -   ةرسا ةنودم مسا نوناقلا اذه ىلع قلطي   article_2:   answers:     ىر خأ   ةي سن جل ا   ن ي لماح  اون ا ك   ولو  ةب ر اغ م لا   ع ي م ج  ىلع   -   1       ىلع   يف ةخر ؤم لا   ف ي ن ج  ةي ق افت اقبط   ، ة ي سن جلا   وم ي دع   مهيف   ن م ب   ن ي ئ جلا 28     ز ويل وي 1951   ن ي ئ ج لا ةي ع ضوب   ةقلعتملا   -   2     اه ي ف ن وك ي   يتلا   تاق ع لا   ىلع   اي ب ر غ م   ن ي ف ر ط لا   دحأ   -   3     ةي ب ر غ م لا   ةي ر ب ع لا   ةي ص خشل ا لاوحا   د ع او ق مه ي لع  ير ست ف   ةب ر اغ م لا   دوه ي لا   ام أ   -   4     3 . 1 . 1 .   P re pro ce s s ing   o f   leg a t ex t   T y p icall y ,   le g al  d o cu m e n tatio n   is   m a n ag ed   b y   th r ele v an Mo r o cc an   m in is tr y ,   w h ic h   u s e s   co m m o n   f o r m at  f o r   all  leg a d o cu m e n t s ,   in cl u d in g   t h m i n is tr y s   w a ter m ar k ,   h ea d er f o o ter ,   an d   p r ea m b le.   All  t h ese   d o cu m en ts   ar p u b lis h ed   o n li n in   P DF   f o r m at.   T o   ex tr ac o n l y   t h le g al  c lau s es  f r o m   th e s d o cu m en ts ,   w e   u s e   th P y t h o n   lib r ar y   P y M u P D F   f o r   ad v an ce d   P DF  m an ip u latio n ,   as  w ell  as  its   p o w er f u l   h an d lin g   o f   A r ab ic  ch ar ac ter s   an d   r ig h t - to - le f t   ( R T L )   r ea d in g   d ir ec tio n .   T h is   ex tr ac ti o n   s h o u ld   s i g n if ican t l y   i m p r o v r etr iev a l   ac cu r ac y ,   as  it  en s u r es  th at  t h v ec to r   d atab ase  co n tain s   o n l y   t ex th at  i s   s e m an ticall y   r ele v a n to   p o ten tial  leg al   q u er ies,  th u s   i m p r o v in g   t h s i g n al - to - n o is r atio .   T o   f ac ilit ate   th r etr iev a to o l s   ex p lo itatio n   o f   t h d atase t,  w e   r e m o v ed   d iacr itical  m ar k s   ( ta s h k ee l) ,   w h ic h   ch a n g th p r o n u n cia tio n   b u n o t h f u n d a m e n tal  m ea n in g .   T h ex p ec ted   i m p ac i s   a n   i n cr ea s in   t h r etr iev al   r ate,   as  t h i s   av o id s   in co n s i s ten c ies  d u to   th p r ese n ce   o f   d iacr itical  m ar k s   in   t h s o u r ce   tex t,  b u t a b s e n t f r o m   th u s er   q u er y .   W th en   s ta n d ar d ized   th A r a b ic  ch ar ac ter s   b y   r ep lacin g   th d if f er e n f o r m s   o f   t h A r ab i lette r s   ،ة )   آ  ، أ   ، إ )   w it h   s ta n d ar d   s y llab ar y   ( ا  ، ه ) .   T h is   s tep   s ta n d ar d izes  co m m o n   s p ellin g   v ar iatio n s   i n   t h A r ab ic  s cr ip w it h   t h ai m   o f   f u r t h er   i m p r o v in g   d ata  r etr iev al,   e n s u r in g   t h a r elev an d o cu m e n t s   ar n o t m is s ed   d u to   m in o r   an d   s e m a n tica ll y   ir r ele v an t c h ar ac ter   v ar iatio n s .       Evaluation Warning : The document was created with Spire.PDF for Python.
                      I SS N :   1 6 9 3 - 6930   T E L KOM NI K A   T elec o m m u n   C o m p u t E C o n tr o l ,   Vo l.  23 ,   No .   6 Dec em b er   20 25 1 4 9 5 - 1 505   1500   3 . 2 .     E m bed din g   m o del s   E m b ed d in g   m o d els  ar p r o v i n g   to   b v al u ab le  to o ls   f o r   A r ab ic  NL P ,   allo w i n g   to   ca p t u r th s e m a n tic   an d   s y n tactic  n u an ce s   o f   w o r d s .   T h er e   ar d if f er en v ar ian t s   o f   th ese  m o d els,  s u ch   as  A r aB E R T ,   E 5 ( Mic r o s o f t)   m u lt ili n g u al  a n d   o th er s   th a t   o f f er   v ec to r   r ep r esen tatio n s   o f   A r ab ic  w o r d s ,   t h u s   f ac il itatin g   i n f o r m atio n   ex tr ac tio n   [ 1 8 ] .   I n   t h is   w o r k   w u s e   t h r ee   d if f er en t   t y p es   o f   m u lt ili n g u al  e m b ed d in g   m o d el  ( o p en   w ei g h t s h av i n g   o p ti m al  d i m en s io n   f o r   s i m ilar it y   s ea r ch   ta s k   i n   A r ab ic  leg al  co n te x t.   T h B GE - m 3   m o d el  p r o v es  its   s tr en g t h s   w er its   m u ltil i n g u al  ca p ab ilit ies,  its   ab ilit y   to   h a n d le  lo n g   an d   n o is y   te x ts ,   a n d   its   ex ce lle n p er f o r m a n ce   i n   s e m an tic  s i m ilar it y   s ea r c h ,   esp ec iall y   s e m an tic  s i m i lar ities   f o r   th leg a d o cu m e n r etr iev a task ,   it  r el ati v el y   n e w   m o d el   an d   p r o v id es  m ea n i n g f u r ep r esen tatio n s   i n   o v er   1 0 0   lan g u ag e s   an d   at  m u l tip le   d ep th s w o r d ,   p ar ag r ap h ,   an d   f u ll  te x u p   to   8 1 9 2   t o k en s ,   also   it  is   w ell  s u ited   f o r   w id r an g o f   r ec o v er y   tas k s   a n d   s u p p o r ts   m u lti - g r an u lar it y   te x in te g r atio n s   [ 1 9 ] .   Mic r o s o f t s   E 5   m u ltil i n g u al   m o d el  al s o   s u p p o r ts   A r ab ic  la n g u a g a n d   i s   o p t i m ized   f o r   th tas k   o f   s e m a n tic  s i m ilar it y   a n d   p ass ag r etr iev a l,  w h o s e m b e d d in g   d i m e n s io n   is   7 6 8   (E5 - s m al l)   an d   1 0 2 4   ( E 5 - lar g e) .   T h ch o ice  o f   th e   e m b ed d in g   m o d el   is   an   i m p o r tan s tep ,   es p ec iall y   i n   t h A r ab ic  leg al   co n tex t,  w h ic h   h as  s p ec if ic  ch ar ac te r is t ic  s u ch   as  lo n g   an d   co m p lex   s e n te n ce s ,   th in te n s iv u s o f   th p ass iv e,   th m ix tu r e   b et w ee n   m o d er n   le g al  ter m in o lo g y   an d   t h co n ce p o f   tr ad itio n al  I s la m ic  la w .   T h is   c h ar ac ter is tic,   k n o w n   i n   leg al  te x ts ,   lead s   u s   to   th e v al u atio n   o f   e m b ed d in g   m o d els  b ef o r in te g r ati n g   t h e m   i n to   th e   R A ar ch itectu r e .   I n   th is   w o r k ,   w u s t h r ee   e m b ed d in g   m o d els  in   le g al  co n te x r etr iev al  in   o r d er   to   d is tin g u is h   o n a m o n g   t h th r ee   m o d els t h at  is   t h m o s t e f f icien t in   ter m s   o f   ac cu r ac y   a n d   lig h t i n   u s e.     3 . 3 .     I nd ex ing   a nd   s p litt ing   I n d ex i n g   is   p r eli m i n ar y   i n   R A s y s te m s ,   it f ac il itates t h s to r ag e,   r etr iev al,   an d   s i m ilar it y   s ea r ch   o f   v ec to r   r ep r esen tatio n s   es s en ti al  f o r   th r ap id   s ea r c h   o f   r el ev an t   d o cu m e n t s   [ 2 0 ] .   I n   th i s   r eg ar d ,   ef f icie n t   in d ex i n g   allo w s   R A s y s te m s   to   a d ap p er f ec tl y   to   lar g d at ab ases   an d   r etu r n   th m o s r ele v an i n f o r m atio n   to   u s er   q u er ies,  th u s   en ab li n g   f as ter   an d   m o r ac cu r ate  r esp o n s es.  Sp litt in g   is   an   es s en tia an d   d is tin ctiv asp ec t   o f   th s y s te m   to   m an a g t h c o n s id er ab le  s ize  o f   th i n f o r m atio n   te x an d ,   co n s eq u e n tl y ,   t o   m ak d o cu m e n t   p r o ce s s in g   a n d   r ap id   id en tif ic atio n   o f   u s e f u l i n f o r m atio n   p o s s ib le  [ 2 1 ] .   T h er a r tw o   m ai n   d o cu m e n t - s p litt in g   tech n iq u e s   u s ed   in   t h R A s y s te m th r ec u r s i v e   ch ar ac ter   s p litt er   ( R C S)  an d   t h to k e n - b ased   s p litt er   ( T T S),   b u in   th is   w o r k   R C a n d   T T m e th o d   ar n o s u itab le  f o r   leg al  d o cu m e n t s ,   w s p litt i n g   b y   c lau s es  to   p r eser v es  t h i n t eg r it y   o f   ea c h   co m p lete   clau s e ,   r esp ec ts   th e   lo g ical   s tr u ct u r o f   t h le g al  d o cu m en t,  av o id s   s p litt i n g   cla u s i n   t h m id d le  an d   m ai n tai n s   th le g al  co n te x t o f   ea c h   s ec tio n .     3 . 4 .     G ener a t o r   I n   R A s y s te m   a r c h itect u r e,   th g e n er ato r   is   b ased   o n   an   L L t h at  tak e s   as  i n p u t h u s er s   q u er y   ( q u esti o n )   a n d   th e   co n te x s e l ec ted   b y   th r etr ie v al,   i.e .   t h e   tex p o ten tiall y   co n ta in i n g   t h ele m e n ts   o f   t h r esp o n s i n   o r d er   to   p r o d u ce   an   i n f o r m ati v o u tp u t h at  r esp o n d s   to   th q u e r y   e n ter ed   b y   th u s er .   Fo r   g en er ato r   to   g en er ate  an   in f o r m ati v an s w er   to   q u esti o n   f r o m   s p ec if ic  co n tex t,  s tr u ct u r ed   p r o m p p lay s   v ital  r o le  in   h elp i n g   th L L d eter m i n th co n tex an d   t h q u esti o n ,   as  w ell  a s   t h g u id eli n es  to   f o l lo w   i n   th e ir   an s w er s   [ 2 2 ] .   I n   th is   w o r k   an d   g iv e n   th s p ec i f icit y   o f   t h leg al  f ield ,   in   p ar ticu lar   th ac cu r ac y   o f   t h e   in f o r m atio n   to   b g en er ated ,   w u s an   ad ap ted   p r o m p w h ich   d ir ec ts   t h g e n er ato r   to   f o llo w   th f o llo w in g   d ir ec tiv es:     1 .   Yo ar sp ec ia li ze as si st an in   Mo ro cc an   fa mi ly   l aw Yo mu st   an s we on ly   ba se on   the   information contained in the excerpts of context provided below.   2.   If   yo do   no fi nd   th in fo rm at io in   th es ex ce rp ts st at cl ea rl th a th in fo rm at io is n ot   available in the provided documents.   3.  Never invent legal content not explicitly mentioned in the excerpts.   4.   An sw er   in   Ar ab ic   on l y   an us ma xi mu m   of   th r ee   se nt en ce an ma ke   t he   an sw er   ac cu ra te   and concise.   5.   Use the same terms  contained in   the reference text when possible.   Retrieval  and  Generation  for  Legal  Query  {I np ut :}   Us er   qu er Q,   Ve ct or   DB   Vc la us es LL M   Mgen,  embedding   mo de Ee m {Output:}   An sw er   qe mb   ←  Ee mb (Q Em be th e   us er   qu er Cr et ri ev ed   ←  SimilaritySearch  ( qemb Vc la us es k   5)   Re tr ie ve   to p - cl au se Pp ro mp ←  Bu il Pr om pt   ( Cretrieved, Q) Use prompt A ←  Mgen ( Prompt) Generate answer with JAIS  {Return}   A .       4.   E XP E R I M E NT A T I O AN RE SU L T S   4 . 1 .     Ret rie v er   pa rt   I n   th is   s u b s ec tio n ,   w as s ess   th r etr iev er   p ar o n   th M o r o cc an   leg al   d o cu m e n t.  T h e m b ed d in g   m o d el s   w u s in   th i s   w o r k   ar B GE - m 3 ,   E 5 - lar g e,   an d   E 5 - s m all  to   d eter m i n th b est  m o d el  am o n g   th th r e e   w it h   t h ab ilit y   to   h an d le   t h l eg al  co n te x t i n   A r ab ic.   Evaluation Warning : The document was created with Spire.PDF for Python.
T E L KO MN I K A   T elec o m m u n   C o m p u t E C o n tr o l           R etri ev a l - a u g men ted   g en era ti o n   fo r   A r a b ic  leg a l in fo r ma tio n :   t h fa mily  co d ca s s tu d ( Ja ma l H r imec h )   1501   T h ass es s m e n p r o ce s s   b eg i n s   b y   s to r in g   t h le g al  d o cu m en tatio n   in   t h v ec to r   d atab ase  af te r   p r ep r o ce s s in g   an d   s p litt i n g   t h e   d o cu m e n t.  T h en ,   w u s th { q u esti o n a n d   {so u r ce co lu m n s   o f   o u r   d ataset  to   ca lcu late  t h n ec e s s ar y   b e n ch m ar k s   to   q u an ti f y   t h ef f ec ti v e n es s   o f   th r etr ie v er   in   a   R AG  s y s te m .   T h ass ess m e n m etr ic s   u s e d   ar MRR ,   w h ic h   i s   w id el y   u s ed   i n   i n f o r m atio n   r et r iev al  a n d   r ec o m m e n d atio n   s y s te m s .   MR R   ev alu a tes  h o w   w e ll  co r r ec an s w er   o r   r elev an r eso u r ce   is   class i f ied   af ter   q u er y   is   m ad e.   MRR   i s   an   a v e r ag b ased   o n   th p o s itio n s   o f   th f ir s co r r ec r ec ip r o c al  an s w er   o v er   n u m b er   o f   q u er y   q u esti o n s   an d   th er e f o r p r o v id es  s in g le  s co r e.   R ec all@ k   is   u s ed   to   ev alu ate  f o r   in f o r m atio n   r etr iev al   s y s te m s .   I in v esti g ate s   th f r a ctio n   o f   r elev a n d o cu m en t s   t h at  ar r etr iev ed   in   th to p   k   d o cu m en ts   r etu r n ed   b y   s y s te m .   T h er ef o r e,   it  q u an ti f ies  h o w   e f f ec ti v s y s te m   is   at  s u r f ac in g   ite m s   t h at  ar tr u l y   o f   in ter es to   u s er .   T h F1   s co r is   p er f o r m a n ce   m e tr ic  th at  is   p r i m ar il y   u s ed   to   ev al u ate  cla s s i f icatio n   m o d els ,   p ar ticu lar l y   i n   th ca s o f   i m b alan ce d   d ata.   I is   th m ea n   h ar m o n ic  o f   p r ec is io n   a n d   r ec all,   allo w i n g   u s   to   o b tain   co m b in ed   s co r th a is   b alan ce d   f o r   f alse  p o s itiv es  an d   f al s n e g ati v es.   T ab le  2   p r esen ts   th e   co m p ar ati v r es u lts   o f   th t h r e e m b ed d in g   m o d el s   ev al u ate d   o n   th ese  m et r ics .       T ab le  2 C o m p ar ativ r es u lt s   o f   e m b ed d in g   m o d els E 5 - l ar g e,   E 5 - s m al l,  B GE - m3   M e t r i c s   E5 - l a r g e   E5 - smal l   B G E - m3   B G E - m3   v s E 5 - l a r g e   B G E - m3   v s E 5 - smal l   R e c a l l @ 1   0 . 9 6 7 0   0 . 9 4 7 0   0 . 9 5 3 0   - 1 . 4 5 %   + 0 . 6 3 %   R e c a l l @ 3   0 . 9 8 6 0   0 . 9 8 4 0   0 . 9 8 5 0   - 0 . 1 0 %   + 0 . 1 0 %   R e c a l l @ 5   0 . 9 9 0 0   0 . 9 8 7 0   0 . 9 8 8 0   - 0 . 2 0 %   + 0 . 1 0 %   F1   0 . 9 6 7 0   0 . 9 4 7 0   0 . 9 5 3 0   - 1 . 4 5 %   + 0 . 6 3 %   M R R   0 . 9 7 6 3   0 . 9 6 4 5   0 . 9 6 8 8   - 0 . 7 7 %   + 0 . 4 5 %   R e t r i e v e r   l a t e n c y   0 . 6 5 7 s   0 . 1 4 5 s   0 . 1 7 8 s   - 0 . 4 7 9 s   + 0 . 0 3 3 s       Af ter   an a l y zi n g   t h r esu l ac co r d in g   to   T ab le  2 ,   w s ee   i n   t h R ec all @ 1   m etr ic  o f   th B GE - m 3   m o d el   r ea ch in g   9 5 . 3 %,  w h ic h   is   les s   th an   1 . 4 co m p ar ed   to   E 5 - lar g an d   0 . 6 m o r ac cu r ate  th an   E 5 - s m all.   T h u s ,   in   th R ec all @ 5   m etr ic  o f   t h e   s a m m o d el,   v al u e   o f   9 8 . 8 %,  w h ic h   is   p r ac ticall y   eq u iv alen t o   E 5 - l ar g ( a   d if f er e n ce   o f   0 . 2 %),   an d   s u p er io r   to   E 5 - s m al l.  A t   t h M R R   m etr ic  lev el,   th B GE - m 3   m o d el  ac h iev e s   9 7 %   lo w er   b y   0 . 8 t h a n   E 5 - lar g e   an d   h i g h er   b y   0 . 4 t h an   E 5 - lar g e,   i n d icati n g   a   g o o d   o v er all  p o s itio n i n g   o f   r elev an r es u lts .   A   co n s is ten c y   b et w ee n   R ec all @ 1 ,   F1 @ 1   a n d   MRR   w o u ld   m ea n   th at  f o r   ea ch   q u esti o n ,   th co r r ec t la w   ar tic le  i s   al w a y s   t h f ir s t r es u lt.   An   e x ce lle n p r ec is io n   o f   r elev an ar ticle s   i n   t h f ir s p o s itio n   an d   b ala n ce   o f   p er f o r m a n ce / r eso u r ce s   an d   n ea r - p er f ec t c o v er ag e,   as   w ell   as e x ce lle n s u p p o r t f o r   t h A r ab ic  la n g u a g e,   w as o b s er v ed   in   th e   B GE - m 3   e m b ed d in g   m o d el.   T o   p r o v id clea r er   v is u a r ep r esen tatio n   o f   t h e s f in d i n g s ,   Fi g u r 2   g r ap h icall y   s u m m ar izes  th p er f o r m a n ce   o f   th e m b ed d in g   m o d el s .   Sp ec if icall y ,   Fig u r 2 ( a)   illu s tr at es  th co m p ar ativ e   r esu lt s   ac r o s s   th e   k e y   p er f o r m an ce   m etr ics  d i s cu s s ed ,   v is u all y   co n f ir m i n g   th e   co m p eti tiv p er f o r m an ce   o f   B GE - m 3   a g ain s t h E 5   m o d els.  I n   p ar allel,   Fig u r 2 ( b )   p r esen ts   t h r etr iev a late n c y   f o r   ea c h   m o d el,   h ig h li g h ti n g   t h ef f ic ien c y   o f   B GE - m 3 ,   w h ic h   o f f er s   a   s tr o n g   b alan ce   b et w ee n   s p ee d   an d   ac cu r ac y .   B GE - m 3   is   an   o p ti m a l c h o ice  f o r   p r o d u ctio n   d ep lo y m en t o f   ar ab ic  leg al  r etr ie v al  s y s te m   b ec a u s it :   a)   Of f er s   ex ce l len p er f o r m an ce ;   b)   Of f er s   g o o d   b alan ce   b et w ee n   p er f o r m a n ce   an d   r eso u r ce   c o n s u m p tio n ;   c)   B en ef it s   f r o m   p u r p o s e - b u il t r etr iev al  ar ch itect u r e ;   d)   De m o n s tr ates e x ce lle n A r ab ic  lan g u a g s u p p o r t .           ( a)   ( b )     Fig u r 2 .   C o m p ar is o n   o f   e m b e d d in g   m o d els ;   ( a)   m etr ics a n d   ( b )   laten c y   Evaluation Warning : The document was created with Spire.PDF for Python.
                      I SS N :   1 6 9 3 - 6930   T E L KOM NI K A   T elec o m m u n   C o m p u t E C o n tr o l ,   Vo l.  23 ,   No .   6 Dec em b er   20 25 1 4 9 5 - 1 505   1502   4 . 2 .    G ener a t o pa rt   I n   th i s   s u b s ec tio n ,   w as s es s   t h R AG  s y s te m   o n   g e n er ati n g   an s w er s   to   q u esti o n s   i n   t h Mo r o cc an   le g al  co n te x u s in g   t h B GE - m 3   e m b ed d in g   m o d el.   Ge n er all y ,   t h g e n er ato r   r elie s   o n   a n   L L M,   p r o m p a n d   r etr iev er   s u ch   th a L L r ec ei v es  t h u s er s   q u esti o n   a n d   th e   r etr iev ed   d o cu m e n t   an d   t h e n   u s es  g u id ed   p r o m p t   to   g en er ate  f ac tu al  a n d   n o n - h all u cin a to r y   an s w er ,   th i s   is   wh y   t h u s o f   r o b u s L L i s   ess e n tial  i n   R AG   s y s te m .   A cc o r d in g   to   Sen g u p ta   et  a l [ 2 3 ] J ais  A r ab ic  in s tr u ctio n - b ased   s y s te m   ( J A I S )   is   s tate - of - t h e - ar t,   A r ab ic - ce n tr ic,   i n s tr u ctio n - o p t i m ized   o p en   g en er ati v la n g u ag m o d el  w i th   1 3 B   p ar a m ete r s   an d   b u il o n   t h e   GPT - 3   d ec o d e r   ar ch itectu r e.   J A I S b ei n g   d esi g n ed   an d   tr ain e d   f r o m   th g r o u n d   u p   w ith   v er y   lar g a m o u n t o f   A r ab ic  d ata  ( alo n g s id E n g li s h )   o f ten   g i v es  it  b etter   in tr in s ic  u n d er s ta n d in g   o f   n u a n ce s ,   m o r p h o lo g y ,   s y n ta x ,   an d   p er h ap s   d ialec ts   ( d esp it b ein g   p r i m ar il y   MS A ) .   T h J A I m o d el  is   e v al u ated   ac r o s s   w id r an g o f   A r ab ic   NL P   b en ch m ar k s ,   co v er i n g   r ea s o n i n g ,   k n o w led g e,   m is i n f o r m at io n ,   an d   b ias,  a n d   h a s   b ee n   f o u n d   to   h a v e   s ig n i f ica n tl y   s u p er io r   A r ab ic  k n o w led g an d   r ea s o n in g   ca p ab ilit ies  co m p ar e d   to   all  ex is tin g   o p en   A r ab ic  an d   m u ltil i n g u al  m o d els.   I n   th is   ass es s m en t,  w u s s i x   m etr i cs  to   ass e s s   t h L L M,   n a m el y   co s i n s i m ilar i t y ,   b ilin g u al  ev a lu at io n   u n d er s t u d y   s co r e   ( B L E U )   s co r e,   F1   s co r e,   f aith f u l n es s ,   an s w er   r elev an ce ,   an d   co n te x t   r elev an ce   [ 2 4 ] .   T h p er f o r m a n ce   r esu lts   o f   o u r   R AG  s y s te m 's   g en er ato r ,   ev alu ated   o n   t h Mo r o cc an   la w   d ataset   u s i n g   th e s s i x   m e tr ics,  ar p r esen t ed   i n   T ab le  3 .       T ab le  3 Pe r f o r m a n ce   r esu l t o f   th g e n er ato r   o n   th Mo r o cc an   la w   d ataset     C o si n e - si mi l a r i t y   B L EU   sco r e   B ER T s c o r e   C h r F + +   F 1   sco r e   F a i t h f u l n e ss   A n s w e r   r e l e v a n c e   C o n t e x t   r e l e v a n c e   Jai s - 13B   6 9 %   5 . 7 %   73 %   4 2 , 7 %   2 1 . 9 %   6 7 %   7 9 . 0 9 %   7 3 . 9 %       Af ter   a n a l y zi n g   t h p er f o r m a n ce   r esu lt  o f   t h g en er ato r ,   w f i n d   g o o d   ca p tu r o f   m ea n in g   a n d   co n tex o f   t h an s w er s   w h ic h   in d icate s   a n   e x ce lle n s e m a n tic  u n d er s tan d i n g ,   at  th e   lev e o f   m ea s u r in g   t h e   s i m ilar it y   b et w ee n   g e n er ated   an s w er   an d   r e f er en ce   a n s w er .   I n   t h f o llo w i n g ,   w ca n   n o tice  t h at  t h lo w   v alu o b tai n ed   f o r   th leg a tex w r itte n   in   A r ab ic  is   n o r m al ,   b ec au s e,   o n   th o n h a n d ,   we  f in d   an   e x te n s i v e   s y n o n y m y   -   th a is ,   s e v er al  s y n o n y m o u s   w o r d s   in   s i n g le  la n g u a g ca n   e x p r ess   t h s a m e   n o tio n   o r   id ea ,   a n d ,   o n   th e   o th er   h a n d ,   in   th e   f ie ld   o f   la w ,   ea c h   ter m   u s ed   h as  a   l eg al  a n d   p r ec is m ea n in g ,   t h er ef o r e,   B L E s co r e   d o es  n o d if f er en tiate  b et w ee n   ap p ar en s y n o n y m s   th a m a y   h av e   d if f er en t   leg a i m p licatio n s .   I n   ad d itio n ,   w e   r ec all  th at  in   g e n er al,   th A r ab ic  lan g u a g h a s   r ath er   co m p licated   g r a m m atica s tr u ct u r e,   w it h   ac ce p tab le   w o r d   o r d er   v ar iatio n s .   T h is   also   in f lu e n ce s   t h B L E s co r e,   b ec au s e,   b ein g   b ased   o n   n - g r a m s ,   it  ca n   also   p en alize   f o r m u lat io n s   t h at  ar co r r ec t,  b u t si m p l y   d i f f er   [ 2 5 ] .   Fu r t h er m o r e,   i n   t h co n tex o f   NL P   d ea lin g   w it h   t h A r ab ic  c o r p u s   o f   le g al  tex ts ,   w h er th v ar iab ilit y   o f   th tr a n s la ted   ter m i n o lo g y   an d   th co m p le x   m o r p h o s y n ta x   p o s m aj o r   p r o b lem s ,   t h F 1 s co r s u g g es ts   t h at   th s y s te m   is   co m p ete n e n o u g h   to   p ar tiall y   ca p tu r t h co n c ep tio n   at  s tak b y   m ea n s   o f   d i v er s it y   o f   s u b s u m p tio n   w h i le  b ein g   tr an s lated   b y   an   ad ap ted   s o u r ce   l ex ico n   ev e n   if   it  is   d if f er en f r o m   th r ef er e n ce   f o r m u latio n s .   w also   d ed u ce   s tr o n g   co r r elatio n   an d   g o o d   co h er en ce   b etw ee n   co s in m etr ic s   < - B lu e,   C o s i n < - F1   an d   B lu < - F1 ,   w h ic h   in d icate s   r esp ec ti v el y   th at  t h R AG  s y s te m   h as  a n   u n d e r s tan d in g   t h at  aid s   g en er atio n   an d   an   u n d er s tan d i n g   a n d   v o ca b u lar y   r elate d   to   l ex ical  co h er e n ce .     PRACTICAL CASE: WHAT DO YOUR CORRELATIONS REVEAL?   Question:    ام  طورش يه وزلا ةحص ؟ جا   Reference :     ُ ق ا د ص ل ا و   ِ ن ا د ِ ه ا ّ ش ل ا و   ي ِ ل َ و ل ا   ي ه   ِ ج ا و ز ل ا   ِ ة ح ِ ص   ُ ط و ر ُ ش   Genrerated :     ر ه َ م و   د و ه ُ ش و   ّ ي ِ ل َ و   َ د و ج ُ و   ُ ح ي ح ص ل ا   ُ ج ا و ز ل ا   ُ ب ل َ ط َ ت َ ي   #Resulting metrics:   Cosinus: 0.85 → Excellent (same meaning, identical  concepts)   BLEU: 0.15  →  L ow   (different Word:   (   ا  يلول    يلو ,     ِ ن ا د ِ ه ا ّ ش   د و ه ُ ش ,   ر ه َ م   ق ا د ص )   F1: 0.30  →  Moderate   (some common words:    ُ ج ا و ز ل ا     َ د و ج ُ و   )     T h en ,   af ter   a n al y zin g   t h r e s u lt s   o b tain ed   o n   th e   f a ith f u ln e s s ,   a n s w er   r elev a n ce ,   an d   co n tex t   r elev an ce   m etr ic s .   I n   ter m s   o f   m ea s u r i n g   w h et h er   th g en er ated   r esp o n s is   f ait h f u to   th r etr iev ed   co n tex t,  a   m o d er ate  f id elit y   i n d icate s   t h at  th m o d el  g e n er all y   r e m ai n s   co n s is te n w it h   A r ab ic  leg al  d o cu m en t s .   Fo r   a n s w er   r ele v a n ce ,   w o b s e r v an   ex ce llen t   s co r o f   7 9 . 0 9 %,  s h o w i n g   t h at  t h m o d el  g e n er ates  r ele v a n t   r esp o n s es  to   th p o s ed   q u es ti o n s ,   in   ad d itio n   to   g o o d   ab i lit y   o f   t h s y s te m   to   id en ti f y   an d   u s ap p r o p r iate  co n tex t u al  p ass a g e s ,   s u g g esti n g   an   e f f ec tiv f u n c tio n i n g   o f   t h r etr iev al  m o d u le.   T h d ed u ce d   r esu lts   th e n   lea d   u s   to   id en t if y   t h at  B GE - m 3   is   th b est,  w h ich   m ea n s   t h at  d e v elo p m e n t   co m p a n ies  th at   cr ea te  s i m ilar   ap p licatio n s   i n   t h A r ab   w o r l d   n o w   h a v an   o p en   w ei g h t,  e f f icien an d   p r o v e n   Evaluation Warning : The document was created with Spire.PDF for Python.
T E L KO MN I K A   T elec o m m u n   C o m p u t E C o n tr o l           R etri ev a l - a u g men ted   g en era ti o n   fo r   A r a b ic  leg a l in fo r ma tio n :   t h fa mily  co d ca s s tu d ( Ja ma l H r imec h )   1503   m o d el,   w h ich   ac ce ler ates  t h d ev elo p m en o f   n e w   le g al  tec h n o lo g ies.  T h u s ,   th g o o d   f u n ctio n in g   o f   o u r   R A G   s y s te m   o n   Mo r o cc an   la w   p r o v es  th at  w h a v r eliab le  m et h o d   th at  m a k es  tex t s   th at  ar co n tex tu al l y   co m p le x   ( lik th la w )   ac ce s s ib le  to   th g en er al  p u b lic,   s o m eth in g   th at  h as   s o cial  i m p ac h elp s   p eo p le  ac ce s s   leg al  in f o r m atio n .   Mo r eo v er ,   th l o w   B L E s co r ca lls   o n   th e   r esear ch   co m m u n it y   to   d elv in to   th is   n ich o f   d ev elo p in g   e v alu a tio n   m e th o d s   f o r   A r ab ic,   esp ec iall y   in   s p e cialize d   f ield s   lik la w .   T h ex p er im e n t s   w er r u n   o n   m ac h in w i th   t h f o llo w i n g   s p ec if icat io n s :     GP U:  T 4 × 2     GP m e m o r y   ( V R A M) : 1 6   GB     S y s te m   m e m o r y   ( R A M) : 3 2   G B     Fra m e w o r k : P y T o r ch   T ab le   4   p r o v id q u alitativ ex a m p le s   to   s h o w   th f i n er   p o in ts   o f   t h m o d el s   p er f o r m an ce .   T h in co r r ec t   g en er atio n s   il lu s tr ate   d ea d ly   f ail u r m o d es li k r etu r n in g   f ac tu al l y   i n co r r ec t a n s w er   ( h al lu ci n atio n in   E x a m p le  1   o r   p r o v id in g   t h r ig h b u p er ilo u s l y   i n co m p lete  an s w er   in   E x a m p le   2 .   C o r r ec t   g en er atio n s ,   h o w ev er ,   i n d icate   t h at  th e   s y s te m   i s   ca p ab le  o f   g e n er ati n g   r esp o n s w h ic h   i s   s e m a n tic all y   eq u iv a len t   an d   f ac t u all y   co r r ec f o r   th is   q u es tio n .   S u ch   q u alitati v a n al y s is   i s   i m p o r ta n to   g et  a n   i n s ig h o n   r ea l - w o r ld   r eliab ilit y   o f   t h m o d el  b esid q u an tita tiv p er f o r m an ce .       T ab le   4 .   Q u alitativ e x a m p le s   o f   co r r ec t a n d   in co r r ec t g en er a tio n s   I n c o r r e c t   g e n e r a t i o n s   C o r r e c t   g e n e r a t i o n s   Ex e mp l e   1   :   Q u e st i o n     ن م   ر د ص ي   أ  ب ج ي   ي ذ لا   ف ر ص ت لا   وه ام   ر ذ ع ت ب   هم لع د ع ب   خ س ف ل ا  ب لا ط ؟ ه ب ل ط   ل ب ق ُ ي ل   ب ي ع ل ا   ن م   ء ا ف ش ل ا   R e f e r e n c e   :   جي   م لع لا   د ع ب   ب ي ع لا ب   ا ض ر ل ا  ى لع ل د ي   ا م   خ س ف ل ا  ب ل ا ط  ن م   ر د ص ي   ا  ب هئ ا ف ش   ر ذ ع ت ب   G e n e r a t e d   r e sp o n se   :   ب لا   ل ب ق  هد ق ع ل   د س ا ف لا   ج او ز لا   خ س ف ي   ي ف  ك لذ و  ، هد ع ب و  ء ا ن ي ت ا  ت ا ح لا   : ة -     ي ف  ج اوز لا   ن ا ك   ا ذ إ   ى ف ش ي   ن أ  إ  ، ن ي ج و ز لا   د ح   فوخ م لا   ض ر م لا   ؛ ج اوز لا   د ع ب   ض ي ر م لا -     ؛ ا ث ث   ا ه ق لط  ن م ل  ةت وت ب م لا   لي لح ت   ج او ز لا ب   ج و ز لا   د ص ق  ا ذ إ -     اذ إ   ت ا ح ل ا  ي ف  عقاول ا  قي لطت لا   وأ  ق طلا ب   د ت ع ي   هب وج و   ةلا ح   ي ف  ي لو  ن ود ب   ج اوز لا   ن ا ك ك ذ م لا خ س ف لا ب   م ك ح لا   ر ود ص   لب ق  ، هع أ  ةر و .   Ex e mp l e   2   :   Q u e st i o n s   ؟ ةونب لا و  ةوب ا  ت وب ث   ى لع ب ت ر ت ت   ي ت لا   ت ا ب ج او لا و  ق وق ح لا   ي ه ا م   R e f e r e n c e     ، هن ي د و  هب س ن   ي ف  ها ب أ  عب ت ي ،   ب س ن لا   ل وه ج م   د لو  ةونب   ت ت ب ث   ى ت م ن ب لا و  ةوب ا  ت ا ب ج اوو   قوق ح   ه ي لع ب ت ر ت ي و  ، ج ا وز لا   عن اوم   هن ع   ج ت ن ي و  ن ا ث ر اوتي و ةو ·   g e n e r a t e d   r e sp o n se :   ث ر ا وت لا   قح   هب   ت ب ث ي   Ex e mp l e   1   :   Q u e st i o n s :   ة ب طخ ل ا  ف ي ر ع ت   وه ام   R e f e r e n c e   ةب طخ لا   يه   ر ي ب ع ت   ي أ ب   ن ي فر طل ا     د ع اوتلا   د ي ف ت   ا ه ي لع ف ر ا ع ت م   ةلي س و ج ا وز لا   ى لع   G e n e r a t e d   r e sp o n se     ةب طخ لا ق ع   وهو  ج اوز لا   ى لع   لج ر لا و   ةأ ر م لا   د ع اوت ي ه د   طخ لا   ها ض ت ق م ب   م ز ت لي م ا ب   ةب ي طخ ل ا  و أ  ب ي ، ا هري غ   و أ  هر ي غ   ى لع ةب طخ لا   ن ع   ع ا ن ت   Ex e mp l e   2   :   Q u e st i o n s     لا وح ا ب   قلع ت ي   ا م ي ف  ةب ر ا غ م لا   د وه ي لا   ى لع ي ر س ت   ي ت لا   ةد ع ا ق لا   ي ه ا م ؟ ةي ص خ ش لا   R e f e r e n c e     ةي ر ب ع لا   ةي ص خ ش لا   لا وح ا  د ع ا وق  م ه ي لع ي ر س ت ف  ةب ر ا غ م لا   د وه ي لا ةي ب ر غ م لا   G e n e r a t e d   r e sp o n se :   وق  ي ر س ت ا  د ع ا   ى لع ةي ب ر غ م لا   ةي ر ب ع لا   ةي ص خ ش لا   لا وح ةب ر ا غ م لا   د وه ي لا .         5.   CO NCLU SI O N   T h is   r esear ch   d e m o n s tr ated   th at  p r o p er ly   co n f i g u r ed   R A co u ld   s ig n i f ica n tl y   i m p r o v ac ce s s   to   an d   u n d er s ta n d in g   o f   Mo r o cc an   le g al  i n f o r m atio n ,   p ar tic u lar l y   t h f a m i l y   co d e ,   an   u n d er ex p lo r ed   ar ea ,   s u r p ass in g   th ca p ab ilit ies  o f   s tan d alo n L L Ms.  Sp ec i f ical l y ,   o u r   s y s te m   ac h ie v ed   r etr iev al  r ec all  o f   9 8 f o r   th r elev an t   leg al  ar ticles  a n d   f i n al  an s w er   r elev a n ce   s co r o f   7 9 . 0 9 %,  u n d er s co r i n g   it s   ef f ec ti v e n es s   w h er b aseli n e   m o d el s   o f te n   f ail.   B ased   o n   t h q u a n titat iv r e s u l ts ,   t h i n teg r ated   B GE - m 3   m o d el  p r o v ed   to   b th m o s t   s u itab le  f o r   th i s   ap p licatio n ,   o f f er in g   g o o d   b alan ce   b et w ee n   p er f o r m a n ce ,   ef f icie n c y ,   an d   A r ab ic  lan g u ag e.   T h id en tif icatio n   o f   th B GE - m 3   m o d el  as  o p ti m al  p r o v id es  s o lid   s tar tin g   p o in f o r   f u t u r w o r k   o n   s e m a n tic   r etr iev al  task s   in   A r ab ic  leg al  co n tex t.  T h is   w o r k   r ep r esen ts   s tep   to w ar d s   th r ea d e m o cr atiza tio n   o f   ac ce s s   to   leg al  in f o r m atio n   f o r   th e   Mo r o cc an   p eo p le.   A s   th e s s y s te m s   w ill  b ab le  to   p r o v id e   p r ec is an d   u n d er s ta n d ab le  an s w er s ,   t h e y   ca n   h elp   p eo p le  b etter   u n d er s t a n d   th eir   r i g h t s   a n d   o b lig atio n s   a n d   b r ea k   d o w n   th b ar r ier   b et w ee n   citize n s   a n d   th la w   a n d   it  h i g h l ig h ted   th n ee d   to   ad ap m a x i m u m   len g th   g e n er ato r   to   A r ab ic  in   th B GE - m 3   m o d el   a n d   to   o p tim ize  tr ain i n g   tec h n iq u e s .   F u r th er m o r e,   th is   r esear ch   r esu lted   i n   th e   cr ea tio n   o f   s et  o f   q u e s tio n s   a n d   an s w er s ,   w h ic h   co u ld   b r ef i n ed   an d   d ev elo p ed   f u r t h er .   Ou r   i m m ed iate  p r io r it y   w i ll  b to   i m p r o v th k e y   co m p o n en ts   o f   th R A s y s te m .   T h is   in cl u d e s   o p tim izin g   th B GE - m 3   in te g r atio n   m o d el  o n   o u r   s p ec if ic  leg al  co r p u s   to   f u r th er   s p ec ialize  its   s ea r ch   ca p ab ilit ies.  W also   p lan   t o   ex p lo r m o r ad v an ce d   R A ar ch itectu r e s ,   s u c h   as  t h in te g r atio n   o f   a   r ec lass i f icatio n   m o d el  to   r e f in th r etr ie v ed   d o cu m e n t s   b ef o r th eir   tr an s m is s io n   to   t h g en er ato r .   On   t h o n e   h an d ,   al t h o u g h   b r o ad en in g   t h s co p is   o n o f   t h g u id eli n es  f o r   f u t u r w o r k ,   it   is   e s s en tial  to   v er i f y   o u r   m et h o d o lo g y   in   o t h er   ar ea s   o f   la w ,   s u c h   as  cr i m in al  la w ,   co m m er cial  la w ,   an d   ad m i n i s tr at iv la w ,   as  t h is   w i ll  allo w   test i n g   t h s y s te m s   ab ilit y   to   p r o ce s s   m o r d iv er s a n d   s p ec ialized   le g al  ter m s   a n d   r ea s o n i n g   m o d els,   th u s   co n f ir m i n g   th g e n er aliz ab ilit y   o f   o u r   m eth o d o lo g y .   Fu r t h er m o r e,   an d   i n   o r d er   to   m iti g ate  t h b ia s es  in h er e n in   th e   d ata  g e n er ated   b y   th e   L L M,   w p la n   to   d e v elo p   r ef er en ce   co r p u s ,   f u ll y   a n n o tated   an d   v al id ated   b y   le g al  ex p er ts .   T h is   ex p er t - cu r ated   d ataset  w ill  n o o n l y   s er v as  m o r r eliab le  b en ch m ar k   b u w ill  also   en ab le  m o r s y s te m atic  s tu d y   o f   g e n er atio n   b ias .   Fu r t h er m o r e,   w p lan   to   ex p lo r th d ev elo p m en o f   n e Evaluation Warning : The document was created with Spire.PDF for Python.
                      I SS N :   1 6 9 3 - 6930   T E L KOM NI K A   T elec o m m u n   C o m p u t E C o n tr o l ,   Vo l.  23 ,   No .   6 Dec em b er   20 25 1 4 9 5 - 1 505   1504   d o m ai n - s p ec i f ic  ev al u atio n   m ea s u r es  t h at  g o   b e y o n d   s e m a n tic  s i m ilar it y   to   ass es s   th f ac tu al  ac cu r ac y   a n d   lo g ical  co n s is te n c y   o f   g e n er at ed   leg al  r esp o n s es.       ACK NO WL E D G M E NT S   T h au th o r s   w o u ld   lik to   th an k   th a n o n y m o u s   r ev ie wer s   f o r   th eir   v alu ab le  f ee d b ac k ,   w h ic h   s ig n i f ica n tl y   i m p r o v ed   t h q u a lit y   o f   t h i s   m a n u s cr ip t.       F UNDIN G   I NF O RM AT I O   Au t h o r s   s tate  n o   f u n d i n g   i n v o l v ed .       AUTHO CO NT RIB UT I O NS ST A T E M E NT     T h is   j o u r n al  u s e s   th C o n tr ib u to r   R o les  T ax o n o m y   ( C R ed iT )   to   r ec o g n ize  in d i v id u al  au th o r   co n tr ib u tio n s ,   r ed u c au t h o r s h ip   d is p u tes,  an d   f ac ilit ate  co lla b o r atio n .     Na m o f   Aut ho r   C   M   So   Va   Fo   I   R   D   O   E   Vi   Su   P   Fu   J am al  Hr i m ec h                               Mo h a m m ed   Mg h ar i                               Yo u s s e f   Z az                                 C     C o n c e p t u a l i z a t i o n   M     M e t h o d o l o g y   So     So f t w a r e   Va     Va l i d a t i o n   Fo     Fo r mal   a n a l y si s   I     I n v e st i g a t i o n   R     R e so u r c e s   D   :   D a t a   C u r a t i o n   O   :   W r i t i n g   -   O r i g i n a l   D r a f t   E   :   W r i t i n g   -   R e v i e w   &   E d i t i n g   Vi     Vi su a l i z a t i o n   Su   :     Su p e r v i si o n   P     P r o j e c t   a d mi n i st r a t i o n   Fu     Fu n d i n g   a c q u i si t i o n         CO NF L I C T   O F   I N T E R E S T   ST A T E M E NT     Au t h o r s   s tate  n o   co n f lic t o f   i n t er est.       DATA AV AI L AB I L I T Y   T h d ata  th at  s u p p o r th f i n d in g s   o f   t h i s   s t u d y ,   s p ec i f icall y   t h 2 , 5 0 0   q u esti o n - a n s w er   p air s   g e n er ated   f o r   th is   r esear c h ,   ar av ailab le  f r o m   t h co r r esp o n d in g   a u t h o r ,   J . H. ,   u p o n   r ea s o n ab le  r eq u est.       RE F E R E NC E S   [ 1 ]   M .   S i g a l a ,   A .   B e e r ,   L .   H o d g s o n ,   a n d   A .   O C o n n o r ,   B i g   d a t a   f o r   m e a s u r i n g   t h e   i m p a c t   o f   t o u r i s m   e c o n o m i c   d e v e l o p m e n t   p r o g r a m m e s :   A   p r o c e s s   a n d   q u a l i t y   c r i t e r i a   f r a m e w o r k   f o r   u s i n g   b i g   d a t a ,   B i g   D a t a   a n d   I n n o v a t i o n   i n   T o u r i s m ,   T r a v e l ,   a n d   H o s p i t a l i t y .   S p r i n g e r   S i n g a p o r e p p .   5 7 7 3 ,   2 0 1 9 ,   d o i :   1 0 . 1 0 0 7 / 9 7 8 - 981 - 13 - 6339 - 9 _ 4 .   [ 2 ]   G .   N g u y e n   e t   a l . M a c h i n e   l e a r n i n g   a n d   d e e p   l e a r n i n g   f r a m e w o r k s   a n d   l i b r a r i e s   f o r   l a r g e - s c a l e   d a t a   m i n i n g :   A   s u r v e y ,   A r t i f i c i a l   I n t e l l i g e n c e   R e v i e w ,   v o l .   5 2 ,   n o .   1 ,   p p .   7 7 1 2 4 ,   J u n .   2 0 1 9 ,   d o i :   1 0 . 1 0 0 7 / s 1 0 4 6 2 - 018 - 0 9 6 7 9 - z.   [ 3 ]   C .   S h o r t e n   a n d   T .   M .   K h o s h g o f t a a r ,   A   s u r v e y   o n   i m a g e   d a t a   a u g m e n t a t i o n   f o r   d e e p   l e a r n i n g ,   J o u r n a l   o f   B i g   D a t a ,   v o l .   6 ,   n o .   1 ,   D e c .   2 0 1 9 ,   d o i :   1 0 . 1 1 8 6 / s 4 0 5 3 7 - 0 1 9 - 0 1 9 7 - 0.   [ 4 ]   R .   V i n a y a k u m a r ,   M .   A l a z a b ,   K .   P .   S o m a n ,   P .   P o o r n a c h a n d r a n ,   A .   A l - N e m r a t ,   a n d   S .   V e n k a t r a m a n ,   D e e p   l e a r n i n g   a p p r o a c h   f o r   i n t e l l i g e n t   i n t r u s i o n   d e t e c t i o n   s y s t e m ,   I E E E   A c c e s s ,   v o l .   7 ,   p p .   4 1 5 2 5 4 1 5 5 0 ,   2 0 1 9 ,   d o i :   1 0 . 1 1 0 9 / A C C E S S . 2 0 1 9 . 2 8 9 5 3 3 4 .   [ 5 ]   K .   S i v a r a m a n ,   R .   M .   V .   K r i s h n a n ,   B .   S u n d a r r a j ,   a n d   S .   S .   G o w t h e m ,   N e t w o r k   f a i l u r e   d e t e c t i o n   a n d   d i a g n o s i s   b y   a n a l y z i n g   s y s l o g   a n d   S N S   da t a :   A p p l y i n g   b i g   d a t a   a n a l y s i s   t o   n e t w o r k   o p e r a t i o n s ,   I n t e r n a t i o n a l   J o u r n a l   o f   I n n o v a t i v e   T e c h n o l o g y   a n d   E x p l o r i n g   E n g i n e e r i n g ,   v o l .   8 ,   n o .   9 S 3 ,   p p .   8 8 3 8 8 7 ,   A u g .   2 0 1 9 ,   d o i :   1 0 . 3 5 9 4 0 / i j i t e e . I 3 1 8 7 . 0 7 8 9 S 3 1 9 .   [ 6 ]   A .   D .   D w i v e d i ,   G .   S r i v a s t a v a ,   S .   D h a r ,   a n d   R .   S i n g h ,   A   d e c e n t r a l i z e d   p r i v a c y - p r e s e r v i n g   h e a l t h c a r e   b l o c k c h a i n   f o r   I o T ,   S e n s o r s ,   v o l .   1 9 ,   n o .   2 ,   J a n .   2 0 1 9 ,   d o i :   1 0 . 3 3 9 0 / s 1 9 0 2 0 3 2 6 .   [ 7 ]   F .   A l - T u r j m a n ,   H .   Z a h m a t k e s h ,   a n d   L .   M o s t a r d a ,   Q u a n t i f y i n g   u n c e r t a i n t y   i n   i n t e r n e t   o f   m e d i c a l   t h i n g s   a n d   b i g - d a t a   s e r v i c e s   u s i n g   i n t e l l i g e n c e   a n d   d e e p   l e a r n i n g ,   I E E E   A c c e s s ,   v o l .   7 ,   p p .   1 1 5 7 4 9 1 1 5 7 5 9 ,   2 0 1 9 ,   d o i :   1 0 . 1 1 0 9 / A C C E S S . 2 0 1 9 . 2 9 3 1 6 3 7 .   [ 8 ]   S .   R .   E l - B e l t a g y   a n d   M .   A .   A b d a l l a h ,   E x p l o r i n g   r e t r i e v a l   a u g m e n t e d   g e n e r a t i o n   i n   A r a b i c ,   P r o c e d i a   C o m p u t e r   S c i e n c e ,   v o l .   2 4 4 ,   p p .   2 9 6 3 0 7 ,   2 0 2 4 ,   d o i :   1 0 . 1 0 1 6 / j . p r o c s . 2 0 2 4 . 1 0 . 2 0 3 .   [ 9 ]   H .   A b d e l a z i m ,   M .   T h a r w a t ,   a n d   A .   M o h a m e d ,   S e m a n t i c   e m b e d d i n g s   f o r   A r a b i c   R e t r i e v a l   A u g m e n t e d   G e n e r a t i o n   ( A R A G ) ,   I n t e r n a t i o n a l   J o u r n a l   o f   A d v a n c e d   C o m p u t e r   S c i e n c e   a n d   A p p l i c a t i o n s   ( I J A C S A ) ,   v o l .   1 4 ,   n o .   1 1 ,   2 0 2 3 ,   d o i :   1 0 . 1 4 5 6 9 / i j a c s a . 2 0 2 3 . 0 1 4 1 1 1 3 5 .   [ 1 0 ]   M .   A l s h a m m a r y ,   M .   N .   U d d i n ,   a n d   L .   K h a n ,   R F P G :   Q u e s t i o n - a n s w e r i n g   f r o m   l o w - r e s o u r c e   l a n g u a g e   ( A r a b i c )   t e x t s   u s i n g   f a c t u a l l y   a w a r e   R A G ,   2 0 2 4   I E E E   1 0 t h   I n t e r n a t i o n a l   C o n f e r e n c e   o n   C o l l a b o r a t i o n   a n d   I n t e r n e t   C o m p u t i n g   ( C I C ) .   I E E E ,   p p .   1 0 7 1 1 6 ,   O c t .   2 8 ,   2 0 2 4 ,   d o i :   1 0 . 1 1 0 9 / c i c 6 2 2 4 1 . 2 0 2 4 . 0 0 0 2 3 .   [ 1 1 ]   K .   S .   J a f a r ,   A .   A .   M o h a m m a d ,   A .   A .   I s s a ,   a n d   A .   V .   P a n o v ,   A u t o m a t i n g   t h e   s e a r c h   f o r   l e g a l   i n f o r m a t i o n   i n   A r a b i c :   A   n o v e l   a p p r o a c h   t o   d o c u m e n t   r e t r i e v a l ,   R u s s i a n   T e c h n o l o g i c a l   J o u r n a l ,   v o l .   1 2 ,   n o .   5 ,   p p .   7 1 6 ,   O c t .   2 0 2 4 ,   d o i :   1 0 . 3 2 3 6 2 / 2 5 0 0 - 3 1 6 x - 2024 - 12 - 5 - 7 - 1. .   Evaluation Warning : The document was created with Spire.PDF for Python.