ترغب بنشر مسار تعليمي؟ اضغط هنا
Avatar

الذكاء الصنعي

تطبيقات الذكاء الصنعي, مفاهيم نظرية وعملية, أمثلة وأكواد برمجية

17 - 5 منشورات متابعة
الذكاء الاصطناعي التعلم الآلي Machine learning Artificial intelligence التعلم العميق

فريق من جامعة ستانفورد يطور نموذج لغوي قريب من أداء نموذج ChatGPT بكلفة اقل من 1000 دولار بهذه الطريقة

897  - Shadi طرح Shadi Saleh  
نموذج Alpaca نماذج لغة كبيرة ChatGPT


فريق من جامعة ستافورد قام بتطوير نموذج لغوي كبير LLM ينافس من حيث الأداء نموذج GPT3 تم بناءه بكلفة تقارب 1000$ وتم تسمية هذا النموذج ب Alpaca أو نموذج ألباكا.

يوضح الشكل التالي بنية نظام نموذج Alpaca والحقيقة فهي في غاية البساطة, وتعود بساطة النموذج إلى الاستفادة من النموذج المفتوح المصدر LLaMA الذي أطلقته فيسبوك بالاضافة إلى بناء البيانات التدريبية باستخدام نموذج text-davinci-003 الذي طورته شركة Open AI والذي يعتبر أساس نموذج ChatGPT



لتدريب نموذج لغوي على الشات او تنفيذ الأوامر، تحتاج إلى بيانات تدريبية تدعى instructions تحوي على عينات من الأسئلة والإجابة عنها، هذه العينات تساعد الشبكات العصبية على فهم الآلية التي يجب ان تستخلص فيها الإجابات من نصوص ضخمة.


الصورة بالمرفق توضح تفاصيل الأوامر التي تم توليد بيانات تدريبية من خلالها, حيث الدوائر الصغيرة في المنتصف تعبر عن الفعل الأساسي والدائرة الخارجية تعبر عن ماهو مطلوب بالضبط، مثلا:

  1. أنشأ: لائحة، شعر، جملة، قصة.
  2. أشرح: مفهوم، الأختلاف، المعنى، الهدف.
  3. صنّف: جملة، عنصر, حيوان, كلمة.


باستخدام هذه الأوامر، قام الفريق بتوليد 52 ألف أمر (بكلفة أقل من 500 دولار)  عن طريق إرسال هذه الأسئلة إلى ChatGPT عن طريق Open AI API.



المثال التالي يوضح مثال كامل تم توليده:

 {
        "instruction": "Give three tips for staying healthy.",
        "input": "",
        "output": "1.Eat a balanced diet and make sure to include plenty of fruits and vegetables. \n2. Exercise regularly to keep your body active and strong. \n3. Get enough sleep and maintain a consistent sleep schedule."
    },
    {
        "instruction": "What are the three primary colors?",
        "input": "",
        "output": "The three primary colors are red, blue, and yellow."
    },
    {
        "instruction": "Describe the structure of an atom.",
        "input": "",
        "output": "An atom is made up of a nucleus, which contains protons and neutrons, surrounded by electrons that travel in orbits around the nucleus. The protons and neutrons have a positive charge, while the electrons have a negative charge, resulting in an overall neutral atom. The number of each particle determines the atomic number and the type of atom."
    },
    {
        "instruction": "How can we reduce air pollution?",
        "input": "",
        "output": "There are a number of ways to reduce air pollution, such as shifting to renewable energy sources, encouraging the use of public transportation, prohibiting the burning of fossil fuels, implementing policies to reduce emissions from industrial sources, and implementing vehicle emissions standards. Additionally, individuals can do their part to reduce air pollution by reducing car use, avoiding burning materials such as wood, and changing to energy efficient appliances."
    },




الجميل أنه تم نشر البيانات التدريبية للأوامر على الرابط التالي:

https://raw.githubusercontent.com/tatsu-lab/stanford_alpaca/main/alpaca_data.json


بعد أن أصبحت البيانات جاهزة, تم استخدام الأمر التالي لتدريب النموذج باستخدام مكتبة Transformers 

torchrun --nproc_per_node=4 --master_port=<your_random_port> train.py \
    --model_name_or_path <your_path_to_hf_converted_llama_ckpt_and_tokenizer> \
    --data_path ./alpaca_data.json \
    --bf16 True \
    --output_dir <your_output_dir> \
    --num_train_epochs 3 \
    --per_device_train_batch_size 4 \
    --per_device_eval_batch_size 4 \
    --gradient_accumulation_steps 8 \
    --evaluation_strategy "no" \
    --save_strategy "steps" \
    --save_steps 2000 \
    --save_total_limit 1 \
    --learning_rate 2e-5 \
    --weight_decay 0. \
    --warmup_ratio 0.03 \
    --lr_scheduler_type "cosine" \
    --logging_steps 1 \
    --fsdp "full_shard auto_wrap" \
    --fsdp_transformer_layer_cls_to_wrap 'LLaMADecoderLayer' \
    --tf32 True


 بعد ذلك تم تدريب نموذج LLaMA  ب 7 مليار بارامتر باستخدم 4 معالجات رسومية  NVIDIA A100 80GB غيغابايت, من الجدير بالذكر أن معالج واحد من هذا النوع قد يصل سعره إلى 20 الف دولار ولكن باستخدام الحوسبة السحابية ذكر المؤلفين أن التدريب استغرق 3 ساعات بكلفة 100 دولار.


هذه بعض الأمثلة عن إجابة النموذج المطوّر على بعض الأسئلة:



تفاصيل المشروع متاحة على الرابط:

https://github.com/tatsu-lab/stanford_alpaca


mircosoft-partner

هل ترغب بارسال اشعارات عن اخر التحديثات في شمرا-اكاديميا