pkedzia commited on
Commit
8dd9361
·
verified ·
1 Parent(s): a2eaf7f

Upload 9 files

Browse files
README.md CHANGED
@@ -1,3 +1,90 @@
1
- ---
2
- license: cc-by-4.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ **License**: CC‑BY‑4.0
2
+ **Datasets**:
3
+ - `clarin-pl/poquad`
4
+
5
+ **Language(s)**: Polish (pl)
6
+ **Library**: 🤗 Transformers
7
+
8
+ ### Model Overview
9
+
10
+ - **Model name**: `radlab/polish-qa-v2-bnb`
11
+ - **Developer**: [radlab.dev](https://radlab.dev)
12
+ - **Model type**: Extractive Question‑Answering (QA)
13
+ - **Base model**: `sdadas/polish-roberta-large-v2` (fine‑tuned for QA)
14
+ - **Quantization**: 8‑bit inference‑only quantization via **bitsandbytes** (`load_in_8bit=True`, double‑quantization enabled, `qa_outputs` excluded from quantization)
15
+ - **Maximum context size**: 512 tokens
16
+
17
+ ### Intended Use
18
+
19
+ This model is designed for **extractive QA** on Polish text. Given a question and a context passage,
20
+ it returns the most relevant span of the context as the answer.
21
+
22
+ ### Limitations
23
+
24
+ - The model works best with contexts up to 512 tokens. Longer passages should be truncated or split.
25
+ - 8‑bit quantization reduces memory usage and inference latency but may introduce a slight drop in accuracy
26
+ compared with the full‑precision model.
27
+ - Only suitable for inference; it cannot be further fine‑tuned while kept in 8‑bit mode.
28
+
29
+ ### How to Use
30
+
31
+ ```python
32
+ from transformers import pipeline
33
+
34
+ model_path = "radlab/polish-qa-v2-bnb"
35
+
36
+ qa = pipeline(
37
+ "question-answering",
38
+ model=model_path,
39
+ )
40
+
41
+ question = "Co będzie w budowanym obiekcie?"
42
+ context = """Pozwolenie na budowę zostało wydane w marcu. Pierwsze prace przygotowawcze
43
+ na terenie przy ul. Wojska Polskiego już się rozpoczęły.
44
+ Działkę ogrodzono, pojawił się również monitoring, a także kontenery
45
+ dla pracowników budowy. Na ten moment nie jest znana lista sklepów,
46
+ które pojawią się w nowym pasażu handlowym."""
47
+
48
+ result = qa(
49
+ question=question,
50
+ context=context.replace("\n", " ")
51
+ )
52
+
53
+ print(result)
54
+ ```
55
+
56
+
57
+ **Sample output**
58
+
59
+ ```json
60
+ {
61
+ "score": 0.32568359375,
62
+ "start": 259,
63
+ "end": 268,
64
+ "answer": "sklepów,"
65
+ }
66
+ ```
67
+
68
+
69
+ ### Technical Details
70
+
71
+ - **Quantization strategy**: `BitsAndBytesStrategy` (8‑bit, double‑quant, `qa_outputs` excluded).
72
+ - **Loading code (for reference)**
73
+
74
+ ```python
75
+ from transformers import AutoConfig, BitsAndBytesConfig, AutoModelForQuestionAnswering
76
+
77
+ config = AutoConfig.from_pretrained(original_path)
78
+ bnb_cfg = BitsAndBytesConfig(
79
+ load_in_8bit=True,
80
+ bnb_8bit_use_double_quant=True,
81
+ bnb_8bit_excluded_modules=["qa_outputs"],
82
+ )
83
+
84
+ model = AutoModelForQuestionAnswering.from_pretrained(
85
+ original_path,
86
+ config=config,
87
+ quantization_config=bnb_cfg,
88
+ device_map="auto",
89
+ )
90
+ ```
added_tokens.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "<mask>": 128000
3
+ }
config.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "RobertaForQuestionAnswering"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "bos_token_id": 0,
7
+ "classifier_dropout": null,
8
+ "dtype": "float16",
9
+ "eos_token_id": 2,
10
+ "hidden_act": "gelu",
11
+ "hidden_dropout_prob": 0.1,
12
+ "hidden_size": 1024,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 4096,
15
+ "layer_norm_eps": 1e-05,
16
+ "max_position_embeddings": 514,
17
+ "model_type": "roberta",
18
+ "num_attention_heads": 16,
19
+ "num_hidden_layers": 24,
20
+ "pad_token_id": 1,
21
+ "position_embedding_type": "absolute",
22
+ "quantization_config": {
23
+ "_load_in_4bit": false,
24
+ "_load_in_8bit": true,
25
+ "bnb_4bit_compute_dtype": "float32",
26
+ "bnb_4bit_quant_storage": "uint8",
27
+ "bnb_4bit_quant_type": "fp4",
28
+ "bnb_4bit_use_double_quant": false,
29
+ "llm_int8_enable_fp32_cpu_offload": false,
30
+ "llm_int8_has_fp16_weight": false,
31
+ "llm_int8_skip_modules": null,
32
+ "llm_int8_threshold": 6.0,
33
+ "load_in_4bit": false,
34
+ "load_in_8bit": true,
35
+ "quant_method": "bitsandbytes"
36
+ },
37
+ "transformers_version": "4.56.2",
38
+ "type_vocab_size": 1,
39
+ "use_cache": true,
40
+ "vocab_size": 128001
41
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:85e32f37e1a7650d21a081cc66686d580e092a6208791aba7cd2fed4bfb897e3
3
+ size 566804116
special_tokens_map.json ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "cls_token": {
10
+ "content": "<s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "eos_token": {
17
+ "content": "</s>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "mask_token": {
24
+ "content": "<mask>",
25
+ "lstrip": true,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "pad_token": {
31
+ "content": "<pad>",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ },
37
+ "sep_token": {
38
+ "content": "</s>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false
43
+ },
44
+ "unk_token": {
45
+ "content": "<unk>",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false
50
+ }
51
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "<s>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": "<pad>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "2": {
21
+ "content": "</s>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "3": {
29
+ "content": "<unk>",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "128000": {
37
+ "content": "<mask>",
38
+ "lstrip": true,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ }
44
+ },
45
+ "bos_token": "<s>",
46
+ "clean_up_tokenization_spaces": true,
47
+ "cls_token": "<s>",
48
+ "eos_token": "</s>",
49
+ "errors": "replace",
50
+ "mask_token": "<mask>",
51
+ "model_max_length": 1000000000000000019884624838656,
52
+ "pad_token": "<pad>",
53
+ "sep_token": "</s>",
54
+ "tokenizer_class": "RobertaTokenizer",
55
+ "trim_offsets": true,
56
+ "unk_token": "<unk>"
57
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2eb8379a2ddcc06c081f2ee53c529e9bab3509adbf924e8246673d4ac50f3040
3
+ size 4027
unigram.json ADDED
The diff for this file is too large to render. See raw diff