توليد المحتوى باستخدام نماذج اللغة الكبيرة (LLM)
توليد المحتوى باستخدام نماذج اللغة الكبيرة (LLM)
مقدمة
يمكن استخدام نماذج اللغة لتوليد أنواع مختلفة من المحتوى بطريقة آلية وإبداعية. يستعرض هذا الدرس الطرق المختلفة لاستخدام LLM في إنشاء المحتوى.
أنواع المحتوى القابلة للتوليد
1. المحتوى التسويقي
- مقالات المدونة
- منشورات وسائل التواصل الاجتماعي
- رسائل البريد الإلكتروني التسويقية
- أوصاف المنتجات
- صفحات الهبوط (Landing pages)
2. المحتوى التقني
- التوثيق التقني
- أدلة الاستخدام
- الدروس التعليمية
- تعليقات الشيفرة البرمجية
- توثيق API
3. المحتوى الإبداعي
- القصص القصيرة
- القصائد
- السيناريوهات (Scripts)
- الحبكات والسيناريوهات الدرامية
- كلمات الأغاني
التنفيذ
1. مولّد المحتوى الأساسي
from openai import OpenAI
import json
class ContentGenerator:
def __init__(self, api_key):
self.client = OpenAI(api_key=api_key)
def generate_content(self, content_type, parameters):
prompt = self._create_prompt(content_type, parameters)
response = self.client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "Tu es un expert en création de contenu."},
{"role": "user", "content": prompt}
],
temperature=0.7
)
return response.choices[0].message.content
def _create_prompt(self, content_type, parameters):
prompts = {
"blog_post": """
Crée un article de blog sur le sujet suivant :
Sujet : {topic}
Ton : {tone}
Longueur : {length} mots
Public cible : {target_audience}
Structure :
1. Introduction accrocheuse
2. Points principaux
3. Exemples et illustrations
4. Conclusion
""",
"social_media": """
Crée un post pour {platform} sur le sujet suivant :
Sujet : {topic}
Ton : {tone}
Hashtags : {hashtags}
Longueur maximale : {max_length} caractères
""",
"product_description": """
Crée une description de produit pour :
Produit : {product_name}
Caractéristiques : {features}
Public cible : {target_audience}
Ton : {tone}
Inclus :
1. Titre accrocheur
2. Description principale
3. Points clés
4. Call-to-action
"""
}
return prompts[content_type].format(**parameters)