LFM2 Arabic Tuned Results
1
1 language
license:apache-2.0
by
YoussefAI
Language Model
OTHER
New
0 downloads
Early-stage
Edge AI:
Mobile
Laptop
Server
Unknown
Mobile
Laptop
Server
Quick Summary
هذا النموذج هو نسخة مُعدلة (Fine-tuned) من LiquidAI/LFM2-2.
Code Examples
🛠️ كيفية الاستخدامpythontransformers
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
import json
# اسم النموذج على Hugging Face
model_id = "YoussefAI/LFM2-Arabic-Tuned-results"
# تحميل النموذج والـ Tokenizer
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id,
device_map="auto",
torch_dtype=torch.bfloat16,
trust_remote_code=True
)
# إنشاء الـ pipeline
pipe = pipeline(
"text-generation",
model=model,
tokenizer=tokenizer,
max_new_tokens=1024,
do_sample=False, # لا نريد إبداعاً، نريد دقة
temperature=0.1
)
# 1. النص الذي تريد تحليله
story_text = """
ذكرت مجلة فوربس أن العائلة تلعب دورا محوريا في تشكيل علاقة الأفراد بالمال،
حيث تتأثر هذه العلاقة بأنماط السلوك المالي المتوارثة عبر الأجيال.
التقرير الذي يستند إلى أبحاث الأستاذ الجامعي شاين إنيت حول
الرفاه المالي يوضح أن لكل شخص "شخصية مالية" تتحدد وفقا لطريقة
تفاعله مع المال، والتي تتأثر بشكل مباشر بتربية الأسرة وتجارب الطفولة.
"""
# 2. رسالة النظام وقالب الـ Schema (يجب أن تكون مطابقة للتدريب)
system_message = (
"You are a professional NLP data parser.\n"
"Follow the provided `Task` by the user and the `Output Scheme` to generate the `Output JSON`.\n"
"Do not generate any introduction or conclusion."
)
# هذا هو القالب الذي "يفهمه" النموذج
# (ملاحظة: هذا مجرد مثال، القالب الفعلي كان أكثر تفصيلاً)
output_scheme = """
{"properties": {"story_title": {"type": "string"}, "story_keywords": {"type": "array"}, "story_summary": {"type": "array"}, "story_category": {"type": "string"}, "story_entities": {"type": "array"}}, "required": ["story_title", "story_keywords", "story_summary", "story_category", "story_entities"]}
"""
# 3. بناء الـ Prompt بنفس تنسيق التدريب
messages = [
{"role": "system", "content": system_message},
{
"role": "user",
"content": f"""# Story:
{story_text.strip()}
# Task:
Extrat the story details into a JSON.
# Output Scheme:
{output_scheme}
# Output JSON:Deploy This Model
Production-ready deployment in minutes
Together.ai
Instant API access to this model
Production-ready inference API. Start free, scale to millions.
Try Free APIReplicate
One-click model deployment
Run models in the cloud with simple API. No DevOps required.
Deploy NowDisclosure: We may earn a commission from these partners. This helps keep LLMYourWay free.