LlamaLens: Specialized Multilingual LLM forAnalyzing News and Social Media Content
Overview
LlamaLens is a specialized multilingual LLM designed for analyzing news and social media content. It focuses on 18 NLP tasks, leveraging 52 datasets across Arabic, English, and Hindi.
The code to replicate the experiments is available on
GitHub
.
Model Inference
To utilize the LlamaLens model for inference, follow these steps:
Install the Required Libraries
:
Ensure you have the necessary libraries installed. You can do this using pip:
pip install transformers torch
Load the Model and Tokenizer:
:
Use the transformers library to load the LlamaLens model and its tokenizer:
from transformers import AutoModelForCausalLM, AutoTokenizer
# Define model path
MODEL_PATH = "QCRI/LlamaLens-Native"# Load model and tokenizer
device_map = "auto"
model = AutoModelForCausalLM.from_pretrained(MODEL_PATH, device_map=device_map)
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH, trust_remote_code=True)
tokenizer.pad_token = tokenizer.eos_token
Prepare the Input:
:
Tokenize your input text:
# Define task and input text
task = "classification"# Change to "summarization" for summarization tasks
input_text = '''دبي - "الخليج": كشفت شركة "لينوفو" أمس عن هاتفها الجديد "فايب زد2 برو" VIBE Z2 Pro، والذي يُعدّ الأقوى والأغنى بالمزايا ضمن سلسلة الهواتف الذكية VIBE رفيعة المستوى بين منتجات الشركة.ويمتاز الهاتف الذكي الفاخر VIBE Z2 Pro بأنه يجمع بين أحدث تقنيات التصوير النقال المتطورة والتصميم الرشيق والنحيف.ويتضمن الهاتف الذكي شاشة كبيرة بقطر 6 بوصات بدقة 2 ليقدم للمستهلكين تجربة بصرية رائعة مع محتوى الوسائط المتعددة.وتستطيع الكاميرا الخلفية المتطورة بدقة 16 ميغابيكسل والمزودة بوظيفة التثبيت البصري للصورة من التقاط صور رائعة دون عناء وتسجيل فيديو فائق الوضوح بدقة 4 لتنافس بذلك الكاميرات المدمجة عالية المستوى.كما يمتاز الهاتف VIBE Z2 Pro بتصميم معدني فريد وملمسٍ يشابه ملمس المعدن المصقول، وأداءٍ سريع بفضل معالج سنابدراغون 801 من كوالكوم، كلّ ذلك في جهاز أنيق ونحيف لا تتجاوز سماكته 7.7 ملم.حساس صورة متفوق ويوفر الهاتف VIBE Z2 Pro مجموعة واسعة من مزايا التصوير الاحترافية، ويمتاز على الهواتف الذكية الأخرى باستخدامه حساس صورة مضاء من الخلف (BSI) بدقة 16 ميغابيكسل ونسبة 16:9 أي أنه يلتقط الصور للشاشة العريضة بالدقة الكاملة.كما تدعم الكاميرا الخلفية تسجيل الفيديو عالي السرعة بمعدل 120 إطاراً في الثانية وبدقة 4.وفضلاً عن ذلك، تتضافر وظيفة التثبيت البصري للصورة والعدسة المؤلفة من 6 عناصر مع ما يقدمه الحساس المضاء من الخلف لضمان أداء قوي للكاميرا في ظروف الإضاءة المنخفضة.شاشة ساطعة فائقة النقاء ويرتقي الهاتف VIBE Z2 Pro فوق المنافسة بشاشةٍ رائعة يبلغ قطرها 6 بوصات تعرض صوراً فائقة النقاء وبألوان واقعية تماماً.ولا تكتفي الشاشة بدقتها العالية (560.2*440.1 بيكسل)، بل إن كثافتها التي تبلغ 490 بكسل في البوصة تضعها في مصاف أفضل الهواتف الذكية على الإطلاق.معالج فائق السرعة وذاكرة وفيرة ويعتمد الهاتف VIBE Z2 Pro على معالج سنابدراغون 801 من كوالكوم، وهو معالج متفوق رباعي النواة يوفر أفضل أداء من حيث السرعة وتعدد المهام.ويستطيع المعالج الذي تصل سرعته إلى 5.2 غيغاهيرتز تحميل التطبيقات وتشغيلها أسرع من المعالجات الأخرى، ويضمن للمستخدمين سلاسة تجربة تعدد المهام بفضل بنيته رباعية النواة وسعة الذاكرة المرفقة بالمعالج والتي تبلغ 3 غيغابايت.ولإتاحة تجربة استخدام طويلة دون انقطاع، تم تزويد الهاتف VIBE Z2 Pro ببطارية عالية السعة، فضلاً عن المزايا المتقدمة لتوفير الطاقة في معالج سنابدراغون 801.'''
instruction = 'صنف المقالة الإخبارية إلى واحدة من الفئات التالية: [ثقافة, تكنولوجيا, طبي, سياسة, دين, تمويل, رياضة].'
output_prefix = "Summary: "if task == "summarization"else"Label: "# Define messages for chat-based prompt format
messages = [
{"role": "system", "content": "You are a social media expert providing accurate analysis and insights."},
{"role": "user", "content": f"{instruction}\nInput: {input_text}"},
{"role": "assistant", "content": output_prefix}
]
# Tokenize input
input_ids = tokenizer.apply_chat_template(
messages,
add_generation_prompt=False,
continue_final_message=True,
tokenize=True,
padding=True,
return_tensors="pt"
).to(model.device)
Generate the Output:
:
Generate a response using the model:
Below, we present the performance of
L-Lens: LlamaLens
, where
"Eng"
refers to the English-instructed model and
"Native"
refers to the model trained with native language instructions. The results are compared against the SOTA (where available) and the Base:
Llama-Instruct 3.1 baseline
. The
Δ
(Delta) column indicates the difference between LlamaLens and the SOTA performance, calculated as (LlamaLens – SOTA).
@article{kmainasi2024llamalensspecializedmultilingualllm,
title={LlamaLens: Specialized Multilingual LLM for Analyzing News and Social Media Content},
author={Mohamed Bayan Kmainasi and Ali Ezzat Shahroor and Maram Hasanain and Sahinur Rahman Laskar and Naeemul Hassan and Firoj Alam},
year={2024},
journal={arXiv preprint arXiv:2410.15308},
volume={},
number={},
pages={},
url={https://arxiv.org/abs/2410.15308},
eprint={2410.15308},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
Runs of QCRI LlamaLens-Native on huggingface.co
9
Total runs
0
24-hour runs
0
3-day runs
3
7-day runs
7
30-day runs
More Information About LlamaLens-Native huggingface.co Model
LlamaLens-Native huggingface.co is an AI model on huggingface.co that provides LlamaLens-Native's model effect (), which can be used instantly with this QCRI LlamaLens-Native model. huggingface.co supports a free trial of the LlamaLens-Native model, and also provides paid use of the LlamaLens-Native. Support call LlamaLens-Native model through api, including Node.js, Python, http.
LlamaLens-Native huggingface.co is an online trial and call api platform, which integrates LlamaLens-Native's modeling effects, including api services, and provides a free online trial of LlamaLens-Native, you can try LlamaLens-Native online for free by clicking the link below.
QCRI LlamaLens-Native online free url in huggingface.co:
LlamaLens-Native is an open source model from GitHub that offers a free installation service, and any user can find LlamaLens-Native on GitHub to install. At the same time, huggingface.co provides the effect of LlamaLens-Native install, users can directly use LlamaLens-Native installed effect in huggingface.co for debugging and trial. It also supports api for free installation.