Downloads · 30 days
30
44% of all-time downloads
MohamedBelal-AI/llama3-writing-prompts-lora
llama3-writing-prompts-lora is a text generation model from MohamedBelal-AI. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as llama3.
Downloads · 30 days
30
44% of all-time downloads
All-time downloads
68
Public
Repo size
185 MB
Likes
0
Public
Click a slice to open those files.
.safetensors168 MB · 91%
From the Hugging Face model README
Built with Meta Llama 3.
هذا الموديل عبارة عن LoRA Adapter تم تدريبه فوق meta-llama/Meta-Llama-3-8B-Instruct لمهمة توليد النصوص المشروط (Conditional Text Generation) باستخدام بيانات WritingPrompts، بحيث يقوم بتحويل عنوان أو فكرة قصيرة (Prompt) إلى قصة مكتوبة.
This model is a LoRA adapter fine-tuned on top of meta-llama/Meta-Llama-3-8B-Instruct for conditional text generation using the WritingPrompts dataset — converting a short prompt/title into a full story.
Evaluated on 20 held-out test titles (small sample, treat as directional):
import torch # مكتبة باي تورش | PyTorch library
from peft import PeftModel # لتحميل الـ adapter | to load the adapter
from transformers import AutoModelForCausalLM, AutoTokenizer # الموديل والتوكنايزر | model and tokenizer classes
base_model_name = "meta-llama/Meta-Llama-3-8B-Instruct" # الموديل الأساسي | the base model
adapter_id = "MohamedBelal-AI/llama3-writing-prompts-lora" # الـ adapter بتاعنا | our adapter
tokenizer = AutoTokenizer.from_pretrained(base_model_name) # تحميل التوكنايزر | load the tokenizer
base_model = AutoModelForCausalLM.from_pretrained( # تحميل الموديل الأساسي | load the base model
base_model_name, # اسم الموديل | model name
torch_dtype=torch.float16, # دقة نصف | half precision
device_map="auto", # توزيع تلقائي على الجهاز | automatic device placement
) # نهاية التحميل | end of loading
model = PeftModel.from_pretrained(base_model, adapter_id) # دمج الـ adapter مع الأساسي | attach the adapter to the base model
title = "The Last Train to Cairo" # عنوان القصة | the story title
messages = [{"role": "user", "content": title}] # رسالة بصيغة المحادثة | chat-format message
inputs = tokenizer.apply_chat_template( # تطبيق قالب Llama-3 | apply the Llama-3 chat template
messages, # الرسائل | the messages
add_generation_prompt=True, # إضافة بداية رد المساعد | add the assistant turn header
return_tensors="pt", # إرجاع تنسورز | return PyTorch tensors
).to(model.device) # نقل للجهاز | move to the device
outputs = model.generate(inputs, max_new_tokens=400, do_sample=True, temperature=0.8, top_p=0.9) # توليد القصة | generate the story
print(tokenizer.decode(outputs[0][inputs.shape[-1]:], skip_special_tokens=True)) # طباعة القصة الجديدة فقط | print only the new tokens
هذا الموديل adapter وليس موديل كامل، يجب تحميله مع الموديل الأساسي meta-llama/Meta-Llama-3-8B-Instruct (Gated model، يتطلب الموافقة على شروط الاستخدام من Meta). تم التدريب على عينة صغيرة (6,341 مثال) وEpoch فعّال واحد، وتم التقييم على 20 عينة فقط، فالنتائج استرشادية.
This is an adapter, not a standalone model — it must be loaded alongside the base model meta-llama/Meta-Llama-3-8B-Instruct (a gated model requiring Meta's license acceptance). It was trained on a small sample (6,341 examples) for a single effective epoch and evaluated on only 20 samples, so results are directional.
