Instructions to use VSSA-SDSA/LT_AI_FakeNews_LLM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use VSSA-SDSA/LT_AI_FakeNews_LLM with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("google/gemma-3-12b-it") model = PeftModel.from_pretrained(base_model, "VSSA-SDSA/LT_AI_FakeNews_LLM") - Transformers
How to use VSSA-SDSA/LT_AI_FakeNews_LLM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="VSSA-SDSA/LT_AI_FakeNews_LLM") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("VSSA-SDSA/LT_AI_FakeNews_LLM", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use VSSA-SDSA/LT_AI_FakeNews_LLM with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "VSSA-SDSA/LT_AI_FakeNews_LLM" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "VSSA-SDSA/LT_AI_FakeNews_LLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/VSSA-SDSA/LT_AI_FakeNews_LLM
- SGLang
How to use VSSA-SDSA/LT_AI_FakeNews_LLM 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 "VSSA-SDSA/LT_AI_FakeNews_LLM" \ --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": "VSSA-SDSA/LT_AI_FakeNews_LLM", "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 "VSSA-SDSA/LT_AI_FakeNews_LLM" \ --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": "VSSA-SDSA/LT_AI_FakeNews_LLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use VSSA-SDSA/LT_AI_FakeNews_LLM with Docker Model Runner:
docker model run hf.co/VSSA-SDSA/LT_AI_FakeNews_LLM
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -3,207 +3,411 @@ base_model: google/gemma-3-12b-it
|
|
| 3 |
library_name: peft
|
| 4 |
pipeline_tag: text-generation
|
| 5 |
tags:
|
| 6 |
-
- base_model:adapter:google/gemma-3-12b-it
|
| 7 |
-
- lora
|
| 8 |
-
- sft
|
| 9 |
-
- transformers
|
| 10 |
-
- trl
|
| 11 |
---
|
| 12 |
|
| 13 |
-
#
|
| 14 |
|
| 15 |
-
|
| 16 |
|
|
|
|
| 17 |
|
|
|
|
| 18 |
|
| 19 |
-
##
|
| 20 |
-
|
| 21 |
-
### Model Description
|
| 22 |
-
|
| 23 |
-
<!-- Provide a longer summary of what this model is. -->
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
- **Developed by:** [More Information Needed]
|
| 28 |
-
- **Funded by [optional]:** [More Information Needed]
|
| 29 |
-
- **Shared by [optional]:** [More Information Needed]
|
| 30 |
-
- **Model type:** [More Information Needed]
|
| 31 |
-
- **Language(s) (NLP):** [More Information Needed]
|
| 32 |
-
- **License:** [More Information Needed]
|
| 33 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 34 |
-
|
| 35 |
-
### Model Sources [optional]
|
| 36 |
-
|
| 37 |
-
<!-- Provide the basic links for the model. -->
|
| 38 |
|
| 39 |
-
-
|
| 40 |
-
- **Paper [optional]:** [More Information Needed]
|
| 41 |
-
- **Demo [optional]:** [More Information Needed]
|
| 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 |
|
| 91 |
-
|
| 92 |
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
-
|
| 96 |
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
|
|
|
| 99 |
|
| 100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
|
| 102 |
-
|
| 103 |
|
| 104 |
-
|
| 105 |
|
| 106 |
-
|
| 107 |
|
| 108 |
-
|
|
|
|
|
|
|
| 109 |
|
| 110 |
-
##
|
| 111 |
|
| 112 |
-
|
|
|
|
|
|
|
| 113 |
|
| 114 |
-
|
| 115 |
|
| 116 |
-
###
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
-
|
| 119 |
|
| 120 |
-
|
| 121 |
|
| 122 |
-
###
|
| 123 |
|
| 124 |
-
|
| 125 |
|
| 126 |
-
|
| 127 |
|
| 128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
|
| 130 |
-
|
| 131 |
|
| 132 |
-
|
| 133 |
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
|
| 136 |
-
|
| 137 |
|
| 138 |
-
###
|
| 139 |
|
|
|
|
| 140 |
|
|
|
|
| 141 |
|
| 142 |
-
|
|
|
|
|
|
|
| 143 |
|
| 144 |
-
|
| 145 |
|
| 146 |
-
|
| 147 |
|
| 148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
|
| 150 |
-
|
| 151 |
|
| 152 |
-
|
| 153 |
|
| 154 |
-
|
| 155 |
-
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
|
| 160 |
-
|
| 161 |
|
| 162 |
-
|
| 163 |
|
| 164 |
-
|
| 165 |
|
| 166 |
-
|
| 167 |
|
| 168 |
-
|
|
|
|
|
|
|
| 169 |
|
| 170 |
-
|
| 171 |
|
| 172 |
-
|
| 173 |
|
| 174 |
-
###
|
| 175 |
|
| 176 |
-
|
| 177 |
|
| 178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
|
| 180 |
-
|
| 181 |
|
| 182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
|
| 184 |
-
|
| 185 |
|
| 186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
|
| 188 |
-
|
| 189 |
|
| 190 |
-
|
| 191 |
|
| 192 |
-
|
| 193 |
|
| 194 |
-
|
|
|
|
|
|
|
| 195 |
|
| 196 |
-
##
|
| 197 |
|
| 198 |
-
|
|
|
|
|
|
|
| 199 |
|
| 200 |
-
|
| 201 |
|
| 202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
|
| 204 |
-
|
| 205 |
|
| 206 |
-
[More Information Needed]
|
| 207 |
### Framework versions
|
| 208 |
|
| 209 |
-
- PEFT 0.18.1
|
|
|
|
| 3 |
library_name: peft
|
| 4 |
pipeline_tag: text-generation
|
| 5 |
tags:
|
| 6 |
+
- base_model:adapter:google/gemma-3-12b-it
|
| 7 |
+
- lora
|
| 8 |
+
- sft
|
| 9 |
+
- transformers
|
| 10 |
+
- trl
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# Gemma3-MIAITS-Adapter
|
| 14 |
|
| 15 |
+
**EN** | [LT](#lt-lietuvių)
|
| 16 |
|
| 17 |
+
---
|
| 18 |
|
| 19 |
+
## EN: English
|
| 20 |
|
| 21 |
+
### Overview
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
**Gemma3-MIAITS-Adapter** is a LoRA adapter fine-tuned on top of [`google/gemma-3-12b-it`](https://huggingface.co/google/gemma-3-12b-it) for Lithuanian-language misinformation classification, developed as part of the **MIAITS** project (_Melagingos informacijos automatinio identifikavimo tekstyno sukūrimas_ - Lithuanian Misinformation Automatic Identification Text Corpus).
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
The model classifies Lithuanian news articles and statements into three categories:
|
| 26 |
|
| 27 |
+
| Label | Meaning |
|
| 28 |
+
| --------------- | --------------------------------- |
|
| 29 |
+
| `Klaidinga` | False / Fake information |
|
| 30 |
+
| `Manipuliatyvu` | Manipulative / Misleading content |
|
| 31 |
+
| `Teisinga` | True / Correct information |
|
| 32 |
|
| 33 |
+
---
|
| 34 |
|
| 35 |
+
### Architecture
|
| 36 |
|
| 37 |
+
- **Base model**: [`google/gemma-3-12b-it`](https://huggingface.co/google/gemma-3-12b-it) - Gemma 3 12B instruction-tuned
|
| 38 |
+
- **Adapter type**: LoRA (PEFT) via QLoRA (4-bit NF4)
|
| 39 |
+
- **Task**: Causal language modelling (text generation) - classification via generated JSON response
|
| 40 |
+
- **LoRA rank (r)**: 32
|
| 41 |
+
- **LoRA alpha**: 64
|
| 42 |
+
- **LoRA dropout**: 0.1
|
| 43 |
+
- **Target modules**: `q_proj`, `v_proj` (attention only)
|
| 44 |
+
- **Bias**: none
|
| 45 |
+
- **Quantization**: 4-bit NF4, compute dtype bfloat16, double quantization enabled
|
| 46 |
+
- **PEFT version**: 0.18.1
|
| 47 |
|
| 48 |
+
---
|
| 49 |
|
| 50 |
+
### Training Data
|
| 51 |
|
| 52 |
+
**Source**: Lithuanian misinformation classification dataset.
|
| 53 |
|
| 54 |
+
**Labels** (3-class):
|
| 55 |
|
| 56 |
+
- `Klaidinga` - False
|
| 57 |
+
- `Manipuliatyvu` - Manipulative
|
| 58 |
+
- `Teisinga` - True
|
| 59 |
|
| 60 |
+
**Text columns**: Each original row was expanded into 3 rows using `7-Statement`, `8-Statement_Context`, and `9-Full_text`. Validation and test sets use `9-Full_text` only.
|
| 61 |
|
| 62 |
+
**Splits**: Stratified 80/10/10.
|
| 63 |
|
| 64 |
+
| Split | Rows |
|
| 65 |
+
| ----- | ------ |
|
| 66 |
+
| Train | 11,976 |
|
| 67 |
+
| Val | 499 |
|
| 68 |
+
| Test | 499 |
|
| 69 |
|
| 70 |
+
---
|
| 71 |
|
| 72 |
+
### Training Hyperparameters
|
| 73 |
|
| 74 |
+
| Parameter | Value |
|
| 75 |
+
| --------------------- | --------------------------- |
|
| 76 |
+
| Learning rate | 2e-5 |
|
| 77 |
+
| Scheduler | Cosine (10% warmup) |
|
| 78 |
+
| Weight decay | 0.05 |
|
| 79 |
+
| Epochs | 3 (early stopping patience 2) |
|
| 80 |
+
| Batch size | 1 |
|
| 81 |
+
| Gradient accumulation | 32 (effective batch = 32) |
|
| 82 |
+
| Max sequence length | 4,096 |
|
| 83 |
+
| Precision | BF16 |
|
| 84 |
+
| Max new tokens (eval) | 512 |
|
| 85 |
|
| 86 |
+
**Selected checkpoint**: epoch 1 (best eval_loss). Runtime: ~11.6h.
|
| 87 |
|
| 88 |
+
---
|
| 89 |
|
| 90 |
+
### Prompt Format
|
| 91 |
|
| 92 |
+
The system prompt instructs the model (in Lithuanian) to classify the text and respond in JSON:
|
| 93 |
|
| 94 |
+
```json
|
| 95 |
+
{"label": "<label>", "justification": "<1-sentence explanation>"}
|
| 96 |
+
```
|
| 97 |
|
| 98 |
+
Ground truth justifications from the `17-Justification` column of the source data were used as assistant responses during training.
|
| 99 |
|
| 100 |
+
---
|
| 101 |
|
| 102 |
+
### Performance
|
| 103 |
|
| 104 |
+
Evaluated on the MIAITS test set (499 rows, 3 classes). Best checkpoint: epoch 1 (by eval_loss).
|
| 105 |
|
| 106 |
+
| Metric | Val | Test |
|
| 107 |
+
| ------------------ | ------ | ------ |
|
| 108 |
+
| Accuracy | 67.1% | 68.0% |
|
| 109 |
+
| Macro F1 | 0.647 | 0.662 |
|
| 110 |
+
| JSON parse failures | 2.4% | 1.8% |
|
| 111 |
|
| 112 |
+
**Epoch progression**:
|
| 113 |
|
| 114 |
+
| Epoch | Val Acc | Val Macro F1 | Test Acc | Test Macro F1 |
|
| 115 |
+
| -------- | ------- | ------------ | -------- | ------------- |
|
| 116 |
+
| 0 (base) | 42.3% | 0.384 | 41.6% | 0.399 |
|
| 117 |
+
| 1 | 65.3% | 0.610 | 66.0% | 0.641 |
|
| 118 |
+
| 2 | 66.7% | 0.643 | 68.2% | 0.668 |
|
| 119 |
+
| 3 | 66.9% | 0.642 | 68.2% | 0.667 |
|
| 120 |
|
| 121 |
+
**Per-class metrics (Test)**:
|
| 122 |
|
| 123 |
+
| Class | Precision | Recall | F1 |
|
| 124 |
+
| ------------- | --------- | ------ | ----- |
|
| 125 |
+
| Klaidinga | 0.637 | 0.717 | 0.675 |
|
| 126 |
+
| Manipuliatyvu | 0.514 | 0.400 | 0.450 |
|
| 127 |
+
| Teisinga | 0.843 | 0.881 | 0.862 |
|
| 128 |
|
| 129 |
+
> **Note:** `Manipuliatyvu` is the hardest class (F1 0.450). `Teisinga` is the easiest (F1 0.862). ~2% of outputs failed JSON parsing.
|
| 130 |
|
| 131 |
+
---
|
| 132 |
|
| 133 |
+
### Intended Use
|
| 134 |
|
| 135 |
+
- Secondary signal in an ensemble alongside ModernBERT
|
| 136 |
+
- Text normalization pre-processing (restoring perturbed Lithuanian text before classification)
|
| 137 |
+
- Research on generative LLMs for Baltic/Eastern European misinformation detection
|
| 138 |
|
| 139 |
+
### Limitations
|
| 140 |
|
| 141 |
+
- Trained exclusively on Lithuanian-language data; not suitable for other languages
|
| 142 |
+
- `Manipuliatyvu` class has notably low recall (0.400)
|
| 143 |
+
- Produces occasional JSON parse failures (~2%)
|
| 144 |
|
| 145 |
+
---
|
| 146 |
|
| 147 |
+
### Usage
|
| 148 |
+
|
| 149 |
+
**Hardware requirements:**
|
| 150 |
+
|
| 151 |
+
- bfloat16 (default): ~24 GB VRAM
|
| 152 |
+
- 4-bit quantization (`--load-in-4bit`): ~8-10 GB VRAM (recommended for consumer GPUs)
|
| 153 |
+
|
| 154 |
+
```python
|
| 155 |
+
import torch
|
| 156 |
+
from peft import PeftModel
|
| 157 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
|
| 158 |
+
|
| 159 |
+
BASE_MODEL = "google/gemma-3-12b-it"
|
| 160 |
+
ADAPTER_PATH = "VSSA-SDSA/LT_AI_FakeNews_LLM"
|
| 161 |
+
|
| 162 |
+
# Optional: 4-bit quantization to reduce VRAM usage
|
| 163 |
+
quantization_config = BitsAndBytesConfig(
|
| 164 |
+
load_in_4bit=True,
|
| 165 |
+
bnb_4bit_compute_dtype=torch.bfloat16,
|
| 166 |
+
bnb_4bit_use_double_quant=True,
|
| 167 |
+
bnb_4bit_quant_type="nf4",
|
| 168 |
+
)
|
| 169 |
+
|
| 170 |
+
tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
|
| 171 |
+
|
| 172 |
+
base_model = AutoModelForCausalLM.from_pretrained(
|
| 173 |
+
BASE_MODEL,
|
| 174 |
+
quantization_config=quantization_config, # remove for full bfloat16
|
| 175 |
+
device_map="auto",
|
| 176 |
+
)
|
| 177 |
+
|
| 178 |
+
model = PeftModel.from_pretrained(base_model, ADAPTER_PATH)
|
| 179 |
+
model.eval()
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
def classify(text: str, max_new_tokens: int = 512) -> dict:
|
| 183 |
+
messages = [
|
| 184 |
+
{
|
| 185 |
+
"role": "system",
|
| 186 |
+
"content": (
|
| 187 |
+
"Esi lietuviškos žiniasklaidos analizės įrankis. "
|
| 188 |
+
"Klasifikuok pateiktą tekstą į vieną iš trijų kategorijų: "
|
| 189 |
+
"Klaidinga, Manipuliatyvu, Teisinga. "
|
| 190 |
+
'Atsakyk JSON formatu: {"label": "<kategorija>", "justification": "<vienas sakinys>"}'
|
| 191 |
+
),
|
| 192 |
+
},
|
| 193 |
+
{"role": "user", "content": text},
|
| 194 |
+
]
|
| 195 |
+
inputs = tokenizer.apply_chat_template(
|
| 196 |
+
messages, return_tensors="pt", add_generation_prompt=True
|
| 197 |
+
).to(model.device)
|
| 198 |
+
with torch.inference_mode():
|
| 199 |
+
output_ids = model.generate(
|
| 200 |
+
inputs,
|
| 201 |
+
max_new_tokens=max_new_tokens,
|
| 202 |
+
do_sample=False,
|
| 203 |
+
repetition_penalty=1.1,
|
| 204 |
+
)
|
| 205 |
+
new_tokens = output_ids[0][inputs.shape[1]:]
|
| 206 |
+
return tokenizer.decode(new_tokens, skip_special_tokens=True)
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
text = "Mokslininkai įrodė, kad žemė yra plokščia ir NASA slepia tiesą."
|
| 210 |
+
print(classify(text))
|
| 211 |
+
```
|
| 212 |
|
| 213 |
+
---
|
| 214 |
|
| 215 |
+
## LT: Lietuvių
|
| 216 |
|
| 217 |
+
### Apžvalga
|
| 218 |
|
| 219 |
+
**Gemma3-MIAITS-Adapter** - tai LoRA adapteris, suderintas ant [`google/gemma-3-12b-it`](https://huggingface.co/google/gemma-3-12b-it) pagrindu lietuviškos dezinformacijos klasifikavimui, sukurtas **MIAITS** projekto (_Melagingos informacijos automatinio identifikavimo tekstyno sukūrimas_) rėmuose.
|
| 220 |
|
| 221 |
+
Modelis klasifikuoja lietuviškus naujienų straipsnius ir teiginius į tris kategorijas:
|
| 222 |
|
| 223 |
+
| Žyma | Reikšmė |
|
| 224 |
+
| --------------- | --------------------------------------- |
|
| 225 |
+
| `Klaidinga` | Klaidinga / melaginga informacija |
|
| 226 |
+
| `Manipuliatyvu` | Manipuliatyvi / klaidinanti informacija |
|
| 227 |
+
| `Teisinga` | Teisinga informacija |
|
| 228 |
|
| 229 |
+
---
|
| 230 |
|
| 231 |
+
### Architektūra
|
| 232 |
|
| 233 |
+
- **Bazinis modelis**: [`google/gemma-3-12b-it`](https://huggingface.co/google/gemma-3-12b-it) - Gemma 3 12B instrukcinė versija
|
| 234 |
+
- **Adapterio tipas**: LoRA (PEFT) per QLoRA (4 bitų NF4)
|
| 235 |
+
- **Užduotis**: Priežastinis kalbos modeliavimas (teksto generavimas) - klasifikavimas per sugeneruotą JSON atsakymą
|
| 236 |
+
- **LoRA rangas (r)**: 32
|
| 237 |
+
- **LoRA alpha**: 64
|
| 238 |
+
- **LoRA dropout**: 0,1
|
| 239 |
+
- **Tiksliniai moduliai**: `q_proj`, `v_proj` (tik dėmesio sluoksniai)
|
| 240 |
+
- **Bias**: nėra
|
| 241 |
+
- **Kvantizacija**: 4 bitų NF4, skaičiavimo tipas bfloat16, dviguba kvantizacija įjungta
|
| 242 |
+
- **PEFT versija**: 0.18.1
|
| 243 |
|
| 244 |
+
---
|
| 245 |
|
| 246 |
+
### Mokymo duomenys
|
| 247 |
|
| 248 |
+
**Šaltinis**: Lietuviškos dezinformacijos klasifikavimo duomenų rinkinys.
|
| 249 |
|
| 250 |
+
**Žymos** (3 klasės):
|
| 251 |
|
| 252 |
+
- `Klaidinga` - Klaidinga
|
| 253 |
+
- `Manipuliatyvu` - Manipuliatyvu
|
| 254 |
+
- `Teisinga` - Teisinga
|
| 255 |
|
| 256 |
+
**Teksto stulpeliai**: Kiekviena originali eilutė buvo išplėsta į 3 eilutes naudojant `7-Statement`, `8-Statement_Context` ir `9-Full_text`. Validavimo ir testavimo rinkiniai naudoja tik `9-Full_text`.
|
| 257 |
|
| 258 |
+
**Padalijimas**: Stratifikuotas 80/10/10.
|
| 259 |
|
| 260 |
+
| Rinkinys | Eilutės |
|
| 261 |
+
| ----------- | ------- |
|
| 262 |
+
| Mokymas | 11 976 |
|
| 263 |
+
| Validavimas | 499 |
|
| 264 |
+
| Testavimas | 499 |
|
| 265 |
|
| 266 |
+
---
|
| 267 |
|
| 268 |
+
### Mokymo hiperparametrai
|
| 269 |
|
| 270 |
+
| Parametras | Reikšmė |
|
| 271 |
+
| --------------------- | --------------------------------- |
|
| 272 |
+
| Mokymosi greitis | 2e-5 |
|
| 273 |
+
| Planuoklis | Kosinusinis (10 % apšilimas) |
|
| 274 |
+
| Svorių atitolimas | 0,05 |
|
| 275 |
+
| Epochos | 3 (ankstyvas stabdymas, kantryb. 2) |
|
| 276 |
+
| Paketų dydis | 1 |
|
| 277 |
+
| Gradiento kaupimas | 32 (efektyvus paketas = 32) |
|
| 278 |
+
| Maks. sekos ilgis | 4 096 |
|
| 279 |
+
| Tikslumas | BF16 |
|
| 280 |
+
| Maks. naujų žetonų (eval) | 512 |
|
| 281 |
|
| 282 |
+
**Pasirinktas kontrolinis taškas**: 1 epocha (geriausias eval_loss). Trukmė: ~11,6 val.
|
| 283 |
|
| 284 |
+
---
|
| 285 |
|
| 286 |
+
### Užklausos formatas
|
| 287 |
|
| 288 |
+
Sistemos užklausa nurodo modeliui (lietuvių kalba) klasifikuoti tekstą ir atsakyti JSON formatu:
|
| 289 |
|
| 290 |
+
```json
|
| 291 |
+
{"label": "<žyma>", "justification": "<vienas sakinys>"}
|
| 292 |
+
```
|
| 293 |
|
| 294 |
+
Mokymo metu kaip asistentu atsakymai naudoti tikrojo šaltinio pagrindinimai iš `17-Justification` stulpelio.
|
| 295 |
|
| 296 |
+
---
|
| 297 |
|
| 298 |
+
### Rezultatai
|
| 299 |
|
| 300 |
+
Įvertinta su MIAITS testavimo rinkiniu (499 eilutės, 3 klasės). Geriausias kontrolinis taškas: 1 epocha (pagal eval_loss).
|
| 301 |
|
| 302 |
+
| Metrika | Validavimas | Testavimas |
|
| 303 |
+
| ---------------------- | ----------- | ---------- |
|
| 304 |
+
| Tikslumas | 67,1 % | 68,0 % |
|
| 305 |
+
| Makro F1 | 0,647 | 0,662 |
|
| 306 |
+
| JSON apdorojimo klaidos | 2,4 % | 1,8 % |
|
| 307 |
|
| 308 |
+
**Epochų progresija**:
|
| 309 |
|
| 310 |
+
| Epocha | Val. tiksl. | Val. makro F1 | Test. tiksl. | Test. makro F1 |
|
| 311 |
+
| ----------- | ----------- | ------------- | ------------ | -------------- |
|
| 312 |
+
| 0 (bazinis) | 42,3 % | 0,384 | 41,6 % | 0,399 |
|
| 313 |
+
| 1 | 65,3 % | 0,610 | 66,0 % | 0,641 |
|
| 314 |
+
| 2 | 66,7 % | 0,643 | 68,2 % | 0,668 |
|
| 315 |
+
| 3 | 66,9 % | 0,642 | 68,2 % | 0,667 |
|
| 316 |
|
| 317 |
+
**Tikslumas pagal klasę (testavimas)**:
|
| 318 |
|
| 319 |
+
| Klasė | Tikslumas | Atkūrimas | F1 |
|
| 320 |
+
| ------------- | --------- | --------- | ----- |
|
| 321 |
+
| Klaidinga | 0,637 | 0,717 | 0,675 |
|
| 322 |
+
| Manipuliatyvu | 0,514 | 0,400 | 0,450 |
|
| 323 |
+
| Teisinga | 0,843 | 0,881 | 0,862 |
|
| 324 |
|
| 325 |
+
> **Pastaba:** `Manipuliatyvu` yra sunkiausia klasė (F1 0,450). `Teisinga` lengviausia (F1 0,862). ~2 % išvesties nepavyko apdoroti JSON formatu.
|
| 326 |
|
| 327 |
+
---
|
| 328 |
|
| 329 |
+
### Numatytas naudojimas
|
| 330 |
|
| 331 |
+
- Papildomas signalas ansamblyje kartu su ModernBERT
|
| 332 |
+
- Teksto normalizavimo išankstinis apdorojimas (sugadintų lietuviškų tekstų atstatymas prieš klasifikavimą)
|
| 333 |
+
- Generatyviųjų kalbos modelių dezinformacijos aptikimo tyrimai Baltijos ir Rytų Europos regione
|
| 334 |
|
| 335 |
+
### Apribojimai
|
| 336 |
|
| 337 |
+
- Modelis apmokytas išimtinai lietuviškais duomenimis; kitoms kalboms netinka
|
| 338 |
+
- `Manipuliatyvu` klasės atkūrimas ypač žemas (0,400)
|
| 339 |
+
- Kartais nepavyksta apdoroti JSON išvesties (~2 %)
|
| 340 |
|
| 341 |
+
---
|
| 342 |
|
| 343 |
+
### Naudojimas
|
| 344 |
+
|
| 345 |
+
**Aparatūros reikalavimai:**
|
| 346 |
+
|
| 347 |
+
- bfloat16 (numatytasis): ~24 GB VRAM
|
| 348 |
+
- 4 bitų kvantizacija: ~8-10 GB VRAM (rekomenduojama vartotojų GPU)
|
| 349 |
+
|
| 350 |
+
```python
|
| 351 |
+
import torch
|
| 352 |
+
from peft import PeftModel
|
| 353 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
|
| 354 |
+
|
| 355 |
+
BASE_MODEL = "google/gemma-3-12b-it"
|
| 356 |
+
ADAPTER_PATH = "VSSA-SDSA/LT_AI_FakeNews_LLM"
|
| 357 |
+
|
| 358 |
+
# Neprivaloma: 4 bitų kvantizacija, siekiant sumažinti VRAM naudojimą
|
| 359 |
+
quantization_config = BitsAndBytesConfig(
|
| 360 |
+
load_in_4bit=True,
|
| 361 |
+
bnb_4bit_compute_dtype=torch.bfloat16,
|
| 362 |
+
bnb_4bit_use_double_quant=True,
|
| 363 |
+
bnb_4bit_quant_type="nf4",
|
| 364 |
+
)
|
| 365 |
+
|
| 366 |
+
tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
|
| 367 |
+
|
| 368 |
+
base_model = AutoModelForCausalLM.from_pretrained(
|
| 369 |
+
BASE_MODEL,
|
| 370 |
+
quantization_config=quantization_config, # pašalinti norint naudoti visą bfloat16
|
| 371 |
+
device_map="auto",
|
| 372 |
+
)
|
| 373 |
+
|
| 374 |
+
model = PeftModel.from_pretrained(base_model, ADAPTER_PATH)
|
| 375 |
+
model.eval()
|
| 376 |
+
|
| 377 |
+
|
| 378 |
+
def classify(text: str, max_new_tokens: int = 512) -> str:
|
| 379 |
+
messages = [
|
| 380 |
+
{
|
| 381 |
+
"role": "system",
|
| 382 |
+
"content": (
|
| 383 |
+
"Esi lietuviškos žiniasklaidos analizės įrankis. "
|
| 384 |
+
"Klasifikuok pateiktą tekstą į vieną iš trijų kategorijų: "
|
| 385 |
+
"Klaidinga, Manipuliatyvu, Teisinga. "
|
| 386 |
+
'Atsakyk JSON formatu: {"label": "<kategorija>", "justification": "<vienas sakinys>"}'
|
| 387 |
+
),
|
| 388 |
+
},
|
| 389 |
+
{"role": "user", "content": text},
|
| 390 |
+
]
|
| 391 |
+
inputs = tokenizer.apply_chat_template(
|
| 392 |
+
messages, return_tensors="pt", add_generation_prompt=True
|
| 393 |
+
).to(model.device)
|
| 394 |
+
with torch.inference_mode():
|
| 395 |
+
output_ids = model.generate(
|
| 396 |
+
inputs,
|
| 397 |
+
max_new_tokens=max_new_tokens,
|
| 398 |
+
do_sample=False,
|
| 399 |
+
repetition_penalty=1.1,
|
| 400 |
+
)
|
| 401 |
+
new_tokens = output_ids[0][inputs.shape[1]:]
|
| 402 |
+
return tokenizer.decode(new_tokens, skip_special_tokens=True)
|
| 403 |
+
|
| 404 |
+
|
| 405 |
+
text = "Mokslininkai įrodė, kad žemė yra plokščia ir NASA slepia tiesą."
|
| 406 |
+
print(classify(text))
|
| 407 |
+
```
|
| 408 |
|
| 409 |
+
---
|
| 410 |
|
|
|
|
| 411 |
### Framework versions
|
| 412 |
|
| 413 |
+
- PEFT 0.18.1
|