Instructions to use Z3NN001/BasicFinQwen-v0.3-Multilingual with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Z3NN001/BasicFinQwen-v0.3-Multilingual with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Z3NN001/BasicFinQwen-v0.3-Multilingual") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("Z3NN001/BasicFinQwen-v0.3-Multilingual") model = AutoModelForMultimodalLM.from_pretrained("Z3NN001/BasicFinQwen-v0.3-Multilingual", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Z3NN001/BasicFinQwen-v0.3-Multilingual with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Z3NN001/BasicFinQwen-v0.3-Multilingual" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Z3NN001/BasicFinQwen-v0.3-Multilingual", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Z3NN001/BasicFinQwen-v0.3-Multilingual
- SGLang
How to use Z3NN001/BasicFinQwen-v0.3-Multilingual 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 "Z3NN001/BasicFinQwen-v0.3-Multilingual" \ --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": "Z3NN001/BasicFinQwen-v0.3-Multilingual", "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 "Z3NN001/BasicFinQwen-v0.3-Multilingual" \ --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": "Z3NN001/BasicFinQwen-v0.3-Multilingual", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Z3NN001/BasicFinQwen-v0.3-Multilingual with Docker Model Runner:
docker model run hf.co/Z3NN001/BasicFinQwen-v0.3-Multilingual
BasicFinQwen v0.3 Multilingual
Author: Z3NN-AI ยท Base model: Qwen3.5-4B (unsloth/Qwen3.5-4B) ยท Weights: bfloat16 (LoRA merged into the base) ยท License: Apache 2.0
BasicFinQwen is a small (4B) assistant for basic finance and fundamental analysis concepts: valuation ratios, margins, cash flow, balance sheet, cost of capital, bonds, options, portfolio and macro basics.
It works in five languages: Spanish (es-ES), English (en-US), French (fr-FR), German (de-DE) and Portuguese (pt-PT). It answers in the language of the question, or in another one if you ask for it.
For each of 207 finance concepts it learned one fixed, verified definition in each language. These are short cards with the definition, how it is calculated, what it indicates, an example and a caveat. It aims to give that same answer reliably, whatever the wording of the question.
What is new in v0.3
| v0.2 | v0.3 | |
|---|---|---|
| Concepts with a verified card | 149 | 207 |
| Ways of asking per concept and language | 7 | ~17 (with article, English name in parentheses, compound questions, "how is it calculated", "how is it used", short form) |
| "Answer in language X" / switching language mid-chat | no | yes |
| Several questions in one message | no | yes |
| Says "I don't know that concept" for made-up terms | no | yes |
Evaluation
Greedy decoding. All test questions use wordings that were not seen in training. Results for the final checkpoint:
| Test | es | en | fr | de | pt |
|---|---|---|---|---|---|
| Card reproduced exactly, new question templates (of 207) | 192 | 194 | 190 | 198 | 178 |
| Card reproduced exactly, new question forms (of 207) | 207 | 206 | 206 | 207 | 207 |
- Question in language X plus "answer in Y": 407 of 414 answers have similarity โฅ 0.90 to the target-language card.
- Made-up concepts (invented names that look like real ratios): the model says it does not know them in 89 of 90 cases.
- Real concepts without a card (Treynor ratio, Black-Scholes, Herfindahl-Hirschman indexโฆ): it does not refuse in 30 of 30 cases. It answers from the base model's knowledge.
- On a 145-question finance exam written by the author (never trained on), the answer is the matching card in 100 cases (v0.2: 12).
The validation loss decreased steadily over training: 0.113 โ 0.088 โ 0.087 โ 0.085 โ 0.085.
Known limitations
- Format instructions lose to the card. "In max 20 words" or "in 3 bullet points" often returns the card instead.
- Concepts without a card are answered by the base model and can contain errors. Example: European vs American options.
- Unknown companies and tickers. It may invent which company a ticker belongs to instead of saying it does not know.
- Portuguese is meant to be European Portuguese, but general-chat answers mix in Brazilian forms.
- Not financial advice. The model is designed to decline stock picks, trading and crypto questions.
Usage
Recommended settings:
- temperature 0 (greedy)
- repetition penalty 1.0
- thinking off (
enable_thinking=False)
Sampling and repetition penalties make the model paraphrase the verified cards and introduce errors.
from transformers import AutoModelForImageTextToText, AutoTokenizer
repo = "Z3NN001/BasicFinQwen-v0.3-Multilingual"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForImageTextToText.from_pretrained(repo, dtype="bfloat16", device_map="auto")
msgs = [{"role": "user", "content": "Was ist das KGV und wie interpretiert man es?"}]
inputs = tok.apply_chat_template(msgs, add_generation_prompt=True, enable_thinking=False,
return_tensors="pt", return_dict=True).to(model.device)
out = model.generate(**inputs, max_new_tokens=900, do_sample=False)
print(tok.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
It also works with vLLM, for example vllm serve Z3NN001/BasicFinQwen-v0.3-Multilingual --max-model-len 4096. In bf16 it needs about 10 GB of GPU memory.
Training
- Data: a private synthetic dataset of about 27,000 conversations (โ12 M tokens). It contains:
- finance concept cards in 5 languages, each verified against public reference sources;
- many paraphrased questions for each card;
- language-switching dialogues;
- multi-question messages;
- refusals for made-up concepts;
- general-chat replay generated by the base model itself, to limit forgetting.
- Method: LoRA SFT with Unsloth. The loss is computed on the assistant responses only.
- rank 16, alpha 32, dropout 0, applied to all attention and MLP projections (21.2 M trainable parameters, 0.47 %)
- 2 epochs, 3,374 steps
- effective batch 16, max length 8,192 tokens
- learning rate 2e-4 with a cosine schedule and 20 warmup steps
- AdamW 8-bit, bf16
- Hardware: 1ร NVIDIA A100 PCIe 40 GB, about 3 h 20 min.
- The LoRA adapter was merged into the base model in bf16.
Versions
- v0.1: Spanish only. Published as
Z3NN001/BasicFinQwen-Spanish-MLX-8bit. - v0.2: Multilingual, 149 concepts. Not published.
- v0.3: Multilingual, 207 concepts. This repository.
- Downloads last month
- -