Text Generation
Transformers
Safetensors
Arabic
qwen2
fine-tuned
arabic
financial-nlp
information-extraction
lora
llama-factory
conversational
text-generation-inference
Instructions to use tegana/qwen2.5-arabic-finance-news-parser with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tegana/qwen2.5-arabic-finance-news-parser with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="tegana/qwen2.5-arabic-finance-news-parser") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("tegana/qwen2.5-arabic-finance-news-parser") model = AutoModelForCausalLM.from_pretrained("tegana/qwen2.5-arabic-finance-news-parser") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use tegana/qwen2.5-arabic-finance-news-parser with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tegana/qwen2.5-arabic-finance-news-parser" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tegana/qwen2.5-arabic-finance-news-parser", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/tegana/qwen2.5-arabic-finance-news-parser
- SGLang
How to use tegana/qwen2.5-arabic-finance-news-parser with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "tegana/qwen2.5-arabic-finance-news-parser" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tegana/qwen2.5-arabic-finance-news-parser", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "tegana/qwen2.5-arabic-finance-news-parser" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tegana/qwen2.5-arabic-finance-news-parser", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use tegana/qwen2.5-arabic-finance-news-parser with Docker Model Runner:
docker model run hf.co/tegana/qwen2.5-arabic-finance-news-parser
File size: 3,090 Bytes
38879d0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | ---
language:
- ar
license: apache-2.0
base_model: Qwen/Qwen2.5-1.5B-Instruct
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.
|