--- language: - ar license: apache-2.0 base_model: Qwen/Qwen2.5-1.5B-Instruct library_name: transformers tags: - fine-tuned - arabic - financial-nlp - information-extraction - lora - llama-factory datasets: - custom pipeline_tag: text-generation --- # qwen2.5-arabic-finance-news-parser A fine-tuned version of [Qwen/Qwen2.5-1.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct) for **structured information extraction from Arabic financial news articles**. ## Model Description This model was fine-tuned using **LoRA** via [LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory) on a dataset of ~2,792 Egyptian stock-market news articles. Given a news article and a JSON output schema, the model extracts structured data such as company name, event type, sentiment, financial figures, and a short summary. ## Training Details | Setting | Value | |---|---| | Base model | Qwen/Qwen2.5-1.5B-Instruct | | Fine-tuning method | LoRA (rank 64, all targets) | | Dataset size | 2,792 samples (2,700 train / 92 val) | | Epochs | 3 | | Learning rate | 1e-4 (cosine scheduler) | | Max sequence length | 3,500 tokens | | Hardware | Kaggle T4 GPU | ## Usage ```python from transformers import AutoModelForCausalLM, AutoTokenizer import torch, json model_id = "tegana/qwen2.5-arabic-finance-news-parser" tokenizer = AutoTokenizer.from_pretrained(model_id) model = AutoModelForCausalLM.from_pretrained( model_id, device_map="auto", torch_dtype=torch.bfloat16 ) article = "القاهرة - واصل جهاز مستقبل مصر للتنمية المستدامة..." output_scheme = json.dumps({ "company_name": "اسم الشركة", "event_type": "acquisition|earnings|dividends|...", "sentiment": "positive|negative|neutral", "impact_level": "high|medium|low", "short_summary": "ملخص من 3 إلى 5 جمل" }, ensure_ascii=False) messages = [ {"role": "system", "content": ( "You are a professional Arabic financial news parser.\n" "Extract structured information and return ONLY a valid JSON object." )}, {"role": "user", "content": f"## Article:\n{article}\n\n## Output Scheme:\n{output_scheme}\n\n## Output JSON:"} ] text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True) inputs = tokenizer([text], return_tensors="pt").to(model.device) with torch.no_grad(): out = model.generate(inputs.input_ids, max_new_tokens=512, do_sample=False) out_ids = [o[len(i):] for i, o in zip(inputs.input_ids, out)] print(tokenizer.batch_decode(out_ids, skip_special_tokens=True)[0]) ``` ## Supported Event Types `earnings` · `capital_increase` · `capital_decrease` · `dividends` · `acquisition` · `sale_of_stake` · `financing` · `project` · `board_decision` · `regulatory_approval` · `analysis_financial` · `stock_exchange_decision` · `other` ## Limitations - Trained primarily on Egyptian stock-market news; may underperform on other Arabic financial dialects. - Numerical extraction quality depends on how clearly figures appear in the source text. ## License Apache 2.0 — same as the base model.