Views
No views yet
| Training Loss | Epoch | Step | Validation Loss |
|---|---|---|---|
| 1.5443 | 1.0879 | 50 | 2.6414 |
| 1.1074 | 2.1758 | 100 | 2.6980 |
| Parameter | Value |
|---|---|
| LoRA adapters | ~1-2% parameters updated |
| Learning rate | 3e-05 |
| Epochs | 3 |
| Optimizer | 8-bit + AMP |
| Schedule | Cosine + warmup |
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4# Load model
5model = AutoModelForCausalLM.from_pretrained(
6 "llama-3.1-8B-newspaper_argument_mining",
7 torch_dtype=torch.bfloat16,
8 device_map="auto"
9)
10tokenizer = AutoTokenizer.from_pretrained("llama-3.1-8B-newspaper_argument_mining")
11tokenizer.pad_token = tokenizer.eos_token
12
13# System prompt for argument extraction
14SYSTEM_PROMPT = '''You are an expert at analyzing historical texts and you hate to summarize
15
16OUTPUT FORMAT - EXACTLY these 4 XML tags and NOTHING else:
17<argument>Original argument text OR "NA"</argument>
18<claim>Core claim (implication) in one sentence OR "NA"</claim>
19<explanation>Why this is an argument OR "NA"</explanation>
20<confidence>0-1</confidence>
21
22EXAMPLE WITH STRONG ARGUMENT:
23<argument>Il giornale L'Italia moderna economica e finanziaria nel numero di oggi propone che non si facciano sottoscrizioni, le quali per quanto larghe sarebbero sempre impari ai bisogni, ma che il Parlamento stabilisca pochi centesimi addizionali per ogni lira su tutte le imposte e tasse (esclusi soltanto i dazi doganali la cui misura è vincolata da trattati di commercio).</argument>
24<claim>Private subscriptions are inadequate for earthquake relief; parliamentary taxation would be more effective.</claim>
25<explanation>The newspaper explicitly argues against private subscriptions as insufficient and proposes a specific alternative solution through parliamentary taxation, making a clear comparative argument about funding mechanisms.</explanation>
26<confidence>0.95</confidence>
27
28EXAMPLE WITHOUT ARGUMENT:
29<argument>NA</argument>
30<claim>NA</claim>
31<explanation>NA</explanation>
32<confidence>0.9</confidence>
33
34RULES:
35- CRITICAL: NEVER REPEAT ARGUMENTS - Each argument must be COMPLETELY UNIQUE
36- Only output arguments that appear verbatim (or nearly verbatim) in the text
37- NO SUMMARY; ONLY EXACT EXTRACTION FROM THE TEXT
38- Extract only original text without changes or use NA when you did not find an argument
39- If no argument exists, use NA for ALL fields
40- More than one argument possible for one article'''
41
42# Example article
43article = """Your historical newspaper text here"""
44
45# Prepare messages
46messages = [
47 {"role": "system", "content": SYSTEM_PROMPT},
48 {"role": "user", "content": f"Extract argumentative units from historical text in their original form, no summaries.\n{article}"}
49]
50
51# Generate
52inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)
53outputs = model.generate(
54 inputs,
55 max_new_tokens=800,
56 temperature=0.1,
57 top_p=0.95,
58 repetition_penalty=1.15,
59 do_sample=True,
60 pad_token_id=tokenizer.eos_token_id
61)
62
63response = tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True)
64print(response)1@article{shao2024deepseekmath,
2 title = {{DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models}},
3 author = {Zhihong Shao and Peiyi Wang and Qihao Zhu and Runxin Xu and Junxiao Song and Mingchuan Zhang and Y. K. Li and Y. Wu and Daya Guo},
4 year = 2024,
5 eprint = {arXiv:2402.03300},
6}1@misc{vonwerra2022trl,
2 title = {{TRL: Transformer Reinforcement Learning}},
3 author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
4 year = 2020,
5 journal = {GitHub repository},
6 publisher = {GitHub},
7 howpublished = {\url{https://github.com/huggingface/trl}}
8}1@article{llama3,
2 title={The Llama 3 Herd of Models},
3 author={AI@Meta},
4 year={2024},
5 journal={arXiv preprint arXiv:2407.21783}
6}