Views
No views yet
unsloth/gemma-4-E2B-it trained to extract structured financial intelligence from news articles and produce valid JSON containing:description)keywords)insights)makiisthebes/110kNewsArticlesSentiment dataset.1{
2 "description": "A brief summary of the news article.",
3 "keywords": ["keyword1", "keyword2"],
4 "insights": [
5 {
6 "ticker": "AAPL",
7 "sentiment": "positive|negative|neutral",
8 "sentiment_reasoning": "Detailed explanation of the sentiment for this ticker."
9 }
10 ]
11}1from unsloth import FastModel
2from unsloth.chat_templates import get_chat_template
3
4model, tokenizer = FastModel.from_pretrained(
5 model_name = "makiisthebes/gemma_4_lora_32b_model_financial",
6 max_seq_length = 8192,
7 load_in_4bit = True,
8)
9
10tokenizer = get_chat_template(tokenizer, chat_template="gemma-4-thinking")
11
12article = "Your financial news article text here..."
13
14prompt = f"""Please extract the relevant information from the provided news article in JSON format.
15Provide the output in the following JSON structure:
16
17{{
18 "description": "A brief summary of the news article.",
19 "keywords": ["disclosure", "bankruptcy", "lawsuit"],
20 "insights": [
21 {{
22 "ticker": "AAPL",
23 "sentiment": "positive||negative||neutral",
24 "sentiment_reasoning": "A detailed explanation of the sentiment analysis for the given ticker."
25 }}
26 ]
27}}
28
29These details should be extracted based on the content of the news article provided below.
30Please ensure that the output is in valid JSON format and adheres to the specified structure.
31Do not include anything other than pure JSON in your response, including ```json or any explanatory text.
32News Article: {article}"""
33
34messages = [{"role": "user", "content": [{"type": "text", "text": prompt}]}]
35
36inputs = tokenizer.apply_chat_template(
37 messages,
38 add_generation_prompt=True,
39 return_tensors="pt",
40 tokenize=True,
41 return_dict=True,
42).to("cuda")
43
44outputs = model.generate(
45 **inputs,
46 max_new_tokens=512,
47 use_cache=True,
48 temperature=1.0, top_p=0.95, top_k=64, # Gemma-4 recommended settings
49)
50
51print(tokenizer.decode(outputs[0], skip_special_tokens=True))| Parameter | Value |
|---|---|
| Base model | unsloth/gemma-4-E2B-it |
| Fine-tuning method | QLoRA (4-bit) |
LoRA rank (r) | 8 |
| LoRA alpha | 8 |
| LoRA dropout | 0 |
| Trainable parameters | 61,214,720 / 31,334,301,232 (~0.20%) |
| Vision layers fine-tuned | No (text-only) |
| Context length | 8,192 tokens |
| Chat template | gemma-4-thinking |
| Training steps | 60 |
| Batch size (effective) | 4 (1 per device × 4 gradient accumulation) |
| Learning rate | 2e-4 |
| LR scheduler | Linear |
| Optimiser | AdamW 8-bit |
| Weight decay | 0.001 |
| Warmup steps | 5 |
| Hardware | NVIDIA GB10 (121.69 GB VRAM) |
| Training time | ~110 minutes |
| Peak training VRAM | ~30 GB |
| Loss (final step) | ~0.113 |
train_on_responses_only) was applied — the model only learns from assistant JSON outputs, not the user prompt, which improves JSON formatting accuracy.input) paired with a structured JSON extraction (output)transformers==5.5.0trl (SFTTrainer + SFTConfig)peft (LoRA via FastModel.get_peft_model)datasets==4.3.0makiisthebes/110kNewsArticlesSentiment for details.
---
A few things worth noting before you paste this on HuggingFace:
1. **Base model name discrepancy** — Your notebook filename says `31B` and the saved repo is named `gemma_4_lora_32b_model_financial`, but the actual model loaded in the code is `unsloth/gemma-4-E2B-it` (a much smaller variant). Worth double-checking which base model you actually ran the full training on, and update the card accordingly.
2. **`push_to_hub` typo** — Your save cell pushes to `makiisthebes/gemma_4_lora_32b_model_financial` for the model but `HF_ACCOUNT/gemma_4_lora_32b_model_financial` for the tokenizer — the tokenizer likely didn't upload unless you fixed that.
3. **60 steps caveat** — The card calls this out honestly. If you run a full epoch, bump those training stats.