Views
No views yet
0.4.11base_model: meta-llama/Meta-Llama-3-8B
2model_type: AutoModelForCausalLM
3tokenizer_type: AutoTokenizer
4
5load_in_8bit: false
6load_in_4bit: true
7strict: false
8
9lora_fan_in_fan_out: false
10data_seed: 49
11seed: 49
12
13datasets:
14 - path: ft_data/alpaca_data.jsonl
15 type: alpaca
16dataset_prepared_path: last_run_prepared
17val_set_size: 0.1
18output_dir: ./qlora-alpaca-out
19hub_model_id: pbevan11/llama-3-8b-ocr-correction
20
21adapter: qlora
22lora_model_dir:
23
24sequence_len: 4096
25sample_packing: true
26pad_to_sequence_len: true
27
28lora_r: 32
29lora_alpha: 16
30lora_dropout: 0.05
31lora_target_linear: true
32lora_fan_in_fan_out:
33lora_target_modules:
34
35wandb_project: ocr-ft
36wandb_entity: sncds
37wandb_name: test
38
39gradient_accumulation_steps: 4
40micro_batch_size: 2 # was 16
41eval_batch_size: 2 # was 16
42num_epochs: 3
43optimizer: paged_adamw_32bit
44lr_scheduler: cosine
45learning_rate: 0.0002
46
47train_on_inputs: false
48group_by_length: false
49bf16: auto
50fp16:
51tf32: false
52
53gradient_checkpointing: true
54early_stopping_patience:
55resume_from_checkpoint:
56local_rank:
57logging_steps: 1
58xformers_attention:
59flash_attention: true
60
61loss_watchdog_threshold: 5.0
62loss_watchdog_patience: 3
63
64warmup_steps: 10
65evals_per_epoch: 4
66eval_table_size:
67saves_per_epoch: 1
68debug:
69deepspeed:
70weight_decay: 0.0
71fsdp:
72fsdp_config:
73special_tokens:
74 pad_token: "<|end_of_text|>"1from peft import AutoPeftModelForCausalLM
2from transformers import AutoTokenizer
3model_id='pbevan11/llama-3-8b-ocr-correction'
4model = AutoPeftModelForCausalLM.from_pretrained(model_id).cuda()
5tokenizer = AutoTokenizer.from_pretrained(model_id)
6tokenizer.pad_token = tokenizer.eos_token1def prompt(instruction, inp):
2 return f"""Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
3
4### Instruction:
5{instruction}
6
7### Input:
8{inp}
9
10### Response:
11"""
12
13def prompt_tok(instruction, inp, return_ids=False):
14 _p = prompt(instruction, inp)
15 input_ids = tokenizer(_p, return_tensors="pt", truncation=True).input_ids.cuda()
16 out_ids = model.generate(input_ids=input_ids, max_new_tokens=5000,
17 do_sample=False)
18 ids = out_ids.detach().cpu().numpy()
19 if return_ids: return out_ids
20
21 full_output = tokenizer.batch_decode(ids, skip_special_tokens=True)[0]
22 response_start = full_output.find("### Response:")
23 if response_start != -1:
24 return full_output[response_start + len("### Response:"):]
25 else:
26 return full_output[len(_p):]1# model inputs
2instruction = "You are an assistant that takes a piece of text that has been corrupted during OCR digitisation, and produce a corrected version of the same text."
3inp = "Do Not Kule Oi't hy.er-l'rieed AjijqIi: imac - Analyst (fteuiers) Hcuiers - A | ) | ilf, <;/) in |) nter |iic . conic! deeiilf. l.o sell n lower-|)rieofl wersinn oi its Macintosh cornutor to nttinct ronsnnu-rs already euami'red ot its iPod music jiayo-r untl annoyoil. by sccnrit.y problems ivitJi Willtlows PCs , Piper.iaffray analyst. (Jcne Muster <aid on Tlinrtiday."
4
5# print prediction
6out = prompt_tok(instruction, inp)
7print(out.replace('\\', ' ').strip('\\n'))"Do Not Rule Out Lower-Priced Mac - Analyst (Reuters) Reuters - Apple Inc. may be considering a lower-priced version of its Macintosh computer to attract consumers already enamored of its iPod music player and annoyed by security problems with Windows PCs, PiperJaffray analyst Gene Munster said on Thursday."| Training Loss | Epoch | Step | Validation Loss |
|---|---|---|---|
| 0.5646 | 0.0174 | 1 | 0.6286 |
| 0.3257 | 0.2609 | 15 | 0.2889 |
| 0.2285 | 0.5217 | 30 | 0.2171 |
| 0.1727 | 0.7826 | 45 | 0.1910 |
| 0.1497 | 1.0174 | 60 | 0.1792 |
| 0.1545 | 1.2783 | 75 | 0.1758 |
| 0.1317 | 1.5391 | 90 | 0.1738 |
| 0.1256 | 1.8 | 105 | 0.1699 |
| 0.0941 | 2.0348 | 120 | 0.1676 |
| 0.0723 | 2.2957 | 135 | 0.1783 |
| 0.07 | 2.5565 | 150 | 0.1779 |
| 0.073 | 2.8174 | 165 | 0.1778 |
@misc {peter_j._bevan_2024,
author = { {Peter J. Bevan} },
title = { llama-3-8b-ocr-correction (Revision d4e6e75) },
year = 2024,
url = { https://huggingface.co/pbevan11/llama-3-8b-ocr-correction },
doi = { 10.57967/hf/2790 },
publisher = { Hugging Face }
}