wjbmattingly commited on
Commit
a2f094f
·
verified ·
1 Parent(s): bceb1aa

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: Qwen/Qwen3-8B
4
+ tags:
5
+ - coreference-resolution
6
+ - ner
7
+ - entity-extraction
8
+ - qwen3
9
+ - lora
10
+ - peft
11
+ datasets:
12
+ - wjbmattingly/synthetic-coref
13
+ language:
14
+ - en
15
+ pipeline_tag: text-generation
16
+ ---
17
+
18
+ # Qwen3-8B-Coref-NER
19
+
20
+ A fine-tuned [Qwen3-8B](Qwen/Qwen3-8B) model for **coreference resolution** and **named entity recognition**.
21
+
22
+ This model resolves pronouns and other referring expressions by replacing them with the full entity names, while also tracking entity mentions and their variants.
23
+
24
+ ## Model Description
25
+
26
+ - **Base Model:** [Qwen/Qwen3-8B](https://huggingface.co/Qwen/Qwen3-8B)
27
+ - **Training Dataset:** [wjbmattingly/synthetic-coref](https://huggingface.co/datasets/wjbmattingly/synthetic-coref)
28
+ - **Task:** Coreference Resolution + Entity Tracking
29
+ - **Method:** LoRA (Low-Rank Adaptation)
30
+
31
+ ## Usage
32
+
33
+ ### Installation
34
+
35
+ ```bash
36
+ pip install transformers peft torch
37
+ ```
38
+
39
+ ### Quick Start
40
+
41
+ ```python
42
+ import torch
43
+ from transformers import AutoModelForCausalLM, AutoTokenizer
44
+ from peft import PeftModel
45
+
46
+ # Load base model and tokenizer
47
+ base_model = "Qwen/Qwen3-8B"
48
+ tokenizer = AutoTokenizer.from_pretrained(base_model)
49
+ model = AutoModelForCausalLM.from_pretrained(
50
+ base_model,
51
+ torch_dtype=torch.bfloat16,
52
+ device_map="auto",
53
+ )
54
+
55
+ # Load LoRA adapter
56
+ model = PeftModel.from_pretrained(model, "wjbmattingly/Qwen3-8B-Coref-NER")
57
+
58
+ # Sample text
59
+ text = """Alcuin of York was an Anglo-Latin scholar and teacher. He was born around 735 and became the student of Archbishop Ecgbert at York. At the invitation of Charlemagne, he became a leading scholar at the Carolingian court.
60
+
61
+ In this role as adviser, he took issue with the emperor's policy of forcing pagans to be baptised on pain of death. His arguments seem to have prevailed – Charlemagne abolished the death penalty for paganism in 797."""
62
+
63
+ # Create prompt
64
+ prompt = "Resolve all pronouns in this text, replacing them with the full entity names. Also identify any entity references you find.\n\n" + text
65
+
66
+ messages = [{"role": "user", "content": prompt}]
67
+ input_text = tokenizer.apply_chat_template(
68
+ messages,
69
+ tokenize=False,
70
+ add_generation_prompt=True,
71
+ enable_thinking=False # Disable thinking mode
72
+ )
73
+
74
+ # Generate
75
+ inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
76
+ with torch.no_grad():
77
+ outputs = model.generate(
78
+ **inputs,
79
+ max_new_tokens=2048,
80
+ do_sample=False,
81
+ pad_token_id=tokenizer.pad_token_id,
82
+ )
83
+
84
+ response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
85
+ print(response)
86
+ ```
87
+
88
+ ### Paragraph-by-Paragraph Processing with Entity Tracking
89
+
90
+ For longer documents, process paragraph by paragraph while tracking entities:
91
+
92
+ ```python
93
+ import torch
94
+ import re
95
+ from transformers import AutoModelForCausalLM, AutoTokenizer
96
+ from peft import PeftModel
97
+
98
+ def parse_entity_mappings(response):
99
+ """Parse model response to extract resolved text and entity mappings."""
100
+ if "NEW ENTITY MAPPINGS:" in response:
101
+ parts = response.split("NEW ENTITY MAPPINGS:")
102
+ resolved_text = parts[0].strip()
103
+ mappings_text = parts[1].strip() if len(parts) > 1 else ""
104
+
105
+ entities = {}
106
+ for line in mappings_text.split("\n"):
107
+ line = line.strip()
108
+ if line.startswith("-"):
109
+ match = re.match(r'-\s*([^:]+):\s*\[([^\]]*)\]', line)
110
+ if match:
111
+ entity_name = match.group(1).strip()
112
+ variants = re.findall(r'"([^"]*)"', match.group(2))
113
+ if variants:
114
+ entities[entity_name] = variants
115
+ return resolved_text, entities
116
+ return response.strip(), {}
117
+
118
+ def format_entities_for_prompt(entities):
119
+ """Format known entities for the prompt."""
120
+ lines = ["Entities and their possible references:"]
121
+ for entity_name, variants in entities.items():
122
+ variants_str = ", ".join(f'"{v}"' for v in variants)
123
+ lines.append(f"- {entity_name}: [{variants_str}]")
124
+ return "\n".join(lines)
125
+
126
+ # Load model
127
+ base_model = "Qwen/Qwen3-8B"
128
+ tokenizer = AutoTokenizer.from_pretrained(base_model)
129
+ model = AutoModelForCausalLM.from_pretrained(base_model, torch_dtype=torch.bfloat16, device_map="auto")
130
+ model = PeftModel.from_pretrained(model, "wjbmattingly/Qwen3-8B-Coref-NER")
131
+
132
+ # Your document
133
+ text = """Alcuin of York was an Anglo-Latin scholar and teacher. He was born around 735 and became the student of Archbishop Ecgbert at York. At the invitation of Charlemagne, he became a leading scholar at the Carolingian court.
134
+
135
+ In this role as adviser, he took issue with the emperor's policy of forcing pagans to be baptised on pain of death. His arguments seem to have prevailed – Charlemagne abolished the death penalty for paganism in 797."""
136
+
137
+ # Split into paragraphs
138
+ paragraphs = [p.strip() for p in text.split("\n\n") if p.strip()]
139
+ resolved_paragraphs = []
140
+ cumulative_entities = {}
141
+
142
+ for i, paragraph in enumerate(paragraphs):
143
+ print(f"Processing paragraph {i+1}/{len(paragraphs)}...")
144
+
145
+ # Build prompt
146
+ if i == 0:
147
+ prompt = f"Resolve all pronouns in this text, replacing them with the full entity names. Also identify any entity references you find.\n\n{paragraph}"
148
+ else:
149
+ context = "\n\n".join(resolved_paragraphs[max(0, i-2):i])
150
+ if cumulative_entities:
151
+ known_str = format_entities_for_prompt(cumulative_entities)
152
+ prompt = f"Known {known_str}\n\nGiven this context of preceding text (already resolved):\n\n{context}\n\nResolve all pronouns in this paragraph using the known entities. Also identify any NEW entity references:\n\n{paragraph}"
153
+ else:
154
+ prompt = f"Given this context of preceding text (already resolved):\n\n{context}\n\nResolve all pronouns in this paragraph. Also identify any NEW entity references:\n\n{paragraph}"
155
+
156
+ messages = [{"role": "user", "content": prompt}]
157
+ input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=False)
158
+ inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
159
+
160
+ with torch.no_grad():
161
+ outputs = model.generate(**inputs, max_new_tokens=2048, do_sample=False, pad_token_id=tokenizer.pad_token_id)
162
+
163
+ response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True).strip()
164
+
165
+ # Parse response
166
+ resolved, new_entities = parse_entity_mappings(response)
167
+ resolved_paragraphs.append(resolved)
168
+
169
+ # Update cumulative entities
170
+ for entity_name, variants in new_entities.items():
171
+ if entity_name not in cumulative_entities:
172
+ cumulative_entities[entity_name] = set()
173
+ cumulative_entities[entity_name].update(variants)
174
+
175
+ if new_entities:
176
+ print(f" New entities found: {new_entities}")
177
+
178
+ # Final output
179
+ print("\n" + "="*50)
180
+ print("RESOLVED TEXT:")
181
+ print("="*50)
182
+ print("\n\n".join(resolved_paragraphs))
183
+
184
+ print("\n" + "="*50)
185
+ print("ALL ENTITIES:")
186
+ print("="*50)
187
+ for entity, variants in cumulative_entities.items():
188
+ print(f" {entity}: {list(variants)}")
189
+ ```
190
+
191
+ ## Sample Output
192
+
193
+ **Input:**
194
+ ```
195
+ Alcuin of York was an Anglo-Latin scholar and teacher. He was born around 735 and became the student of Archbishop Ecgbert at York. At the invitation of Charlemagne, he became a leading scholar at the Carolingian court.
196
+
197
+ In this role as adviser, he took issue with the emperor's policy of forcing pagans to be baptised on pain of death. His arguments seem to have prevailed – Charlemagne abolished the death penalty for paganism in 797.
198
+ ```
199
+
200
+ **Output:**
201
+ ```
202
+ Alcuin of York was an Anglo-Latin scholar and teacher. Alcuin of York was born around 735 and became the student of Archbishop Ecgbert at York. At the invitation of Charlemagne, Alcuin of York became a leading scholar at the Carolingian court.
203
+
204
+ In Alcuin of York's role as adviser, Alcuin of York took issue with Charlemagne's policy of forcing pagans to be baptised on pain of death. Alcuin of York's arguments seem to have prevailed – Charlemagne abolished the death penalty for paganism in 797.
205
+
206
+ NEW ENTITY MAPPINGS:
207
+ - Alcuin of York: ["He", "his", "he"]
208
+ - Charlemagne: ["the emperor"]
209
+ ```
210
+
211
+ ## Training Details
212
+
213
+ This model was trained using:
214
+ - **LoRA rank:** 16
215
+ - **LoRA alpha:** 32
216
+ - **Target modules:** q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
217
+ - **Training mode:** Paragraph-by-paragraph with progressive entity tracking
218
+
219
+ ## Citation
220
+
221
+ If you use this model, please cite the training dataset and base model.
222
+
223
+ ## License
224
+
225
+ Apache 2.0
adapter_config.json ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "auto_mapping": null,
6
+ "base_model_name_or_path": "Qwen/Qwen3-8B",
7
+ "bias": "none",
8
+ "corda_config": null,
9
+ "ensure_weight_tying": false,
10
+ "eva_config": null,
11
+ "exclude_modules": null,
12
+ "fan_in_fan_out": false,
13
+ "inference_mode": true,
14
+ "init_lora_weights": true,
15
+ "layer_replication": null,
16
+ "layers_pattern": null,
17
+ "layers_to_transform": null,
18
+ "loftq_config": {},
19
+ "lora_alpha": 32,
20
+ "lora_bias": false,
21
+ "lora_dropout": 0.1,
22
+ "megatron_config": null,
23
+ "megatron_core": "megatron.core",
24
+ "modules_to_save": [
25
+ "embed_tokens",
26
+ "lm_head"
27
+ ],
28
+ "peft_type": "LORA",
29
+ "peft_version": "0.18.1",
30
+ "qalora_group_size": 16,
31
+ "r": 16,
32
+ "rank_pattern": {},
33
+ "revision": null,
34
+ "target_modules": [
35
+ "k_proj",
36
+ "gate_proj",
37
+ "v_proj",
38
+ "q_proj",
39
+ "o_proj",
40
+ "down_proj",
41
+ "up_proj"
42
+ ],
43
+ "target_parameters": null,
44
+ "task_type": "CAUSAL_LM",
45
+ "trainable_token_indices": null,
46
+ "use_dora": false,
47
+ "use_qalora": false,
48
+ "use_rslora": false
49
+ }
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:922a160cecccc7ed4ae8eadd43850c87fba78782b64483034ce76bb00d9cb307
3
+ size 2663975192
chat_template.jinja ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0].role == 'system' %}
4
+ {{- messages[0].content + '\n\n' }}
5
+ {%- endif %}
6
+ {{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
7
+ {%- for tool in tools %}
8
+ {{- "\n" }}
9
+ {{- tool | tojson }}
10
+ {%- endfor %}
11
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
12
+ {%- else %}
13
+ {%- if messages[0].role == 'system' %}
14
+ {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
15
+ {%- endif %}
16
+ {%- endif %}
17
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
18
+ {%- for message in messages[::-1] %}
19
+ {%- set index = (messages|length - 1) - loop.index0 %}
20
+ {%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
21
+ {%- set ns.multi_step_tool = false %}
22
+ {%- set ns.last_query_index = index %}
23
+ {%- endif %}
24
+ {%- endfor %}
25
+ {%- for message in messages %}
26
+ {%- if message.content is string %}
27
+ {%- set content = message.content %}
28
+ {%- else %}
29
+ {%- set content = '' %}
30
+ {%- endif %}
31
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
32
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
33
+ {%- elif message.role == "assistant" %}
34
+ {%- set reasoning_content = '' %}
35
+ {%- if message.reasoning_content is string %}
36
+ {%- set reasoning_content = message.reasoning_content %}
37
+ {%- else %}
38
+ {%- if '</think>' in content %}
39
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
40
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
41
+ {%- endif %}
42
+ {%- endif %}
43
+ {%- if loop.index0 > ns.last_query_index %}
44
+ {%- if loop.last or (not loop.last and reasoning_content) %}
45
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
46
+ {%- else %}
47
+ {{- '<|im_start|>' + message.role + '\n' + content }}
48
+ {%- endif %}
49
+ {%- else %}
50
+ {{- '<|im_start|>' + message.role + '\n' + content }}
51
+ {%- endif %}
52
+ {%- if message.tool_calls %}
53
+ {%- for tool_call in message.tool_calls %}
54
+ {%- if (loop.first and content) or (not loop.first) %}
55
+ {{- '\n' }}
56
+ {%- endif %}
57
+ {%- if tool_call.function %}
58
+ {%- set tool_call = tool_call.function %}
59
+ {%- endif %}
60
+ {{- '<tool_call>\n{"name": "' }}
61
+ {{- tool_call.name }}
62
+ {{- '", "arguments": ' }}
63
+ {%- if tool_call.arguments is string %}
64
+ {{- tool_call.arguments }}
65
+ {%- else %}
66
+ {{- tool_call.arguments | tojson }}
67
+ {%- endif %}
68
+ {{- '}\n</tool_call>' }}
69
+ {%- endfor %}
70
+ {%- endif %}
71
+ {{- '<|im_end|>\n' }}
72
+ {%- elif message.role == "tool" %}
73
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
74
+ {{- '<|im_start|>user' }}
75
+ {%- endif %}
76
+ {{- '\n<tool_response>\n' }}
77
+ {{- content }}
78
+ {{- '\n</tool_response>' }}
79
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
80
+ {{- '<|im_end|>\n' }}
81
+ {%- endif %}
82
+ {%- endif %}
83
+ {%- endfor %}
84
+ {%- if add_generation_prompt %}
85
+ {{- '<|im_start|>assistant\n' }}
86
+ {%- if enable_thinking is defined and enable_thinking is false %}
87
+ {{- '<think>\n\n</think>\n\n' }}
88
+ {%- endif %}
89
+ {%- endif %}
inference.py ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Coreference Resolution with Qwen3-8B-Coref-NER
4
+
5
+ Usage:
6
+ uv run inference.py input.txt
7
+ uv run inference.py input.txt --output resolved.txt
8
+ uv run inference.py input.txt --html report.html
9
+ """
10
+
11
+ import argparse
12
+ import torch
13
+ import re
14
+ from transformers import AutoModelForCausalLM, AutoTokenizer
15
+ from peft import PeftModel
16
+
17
+ MODEL_ID = "wjbmattingly/Qwen3-8B-Coref-NER"
18
+ BASE_MODEL = "Qwen/Qwen3-8B"
19
+
20
+
21
+ def parse_entity_mappings(response):
22
+ """Parse model response to extract resolved text and entity mappings."""
23
+ if "NEW ENTITY MAPPINGS:" in response:
24
+ parts = response.split("NEW ENTITY MAPPINGS:")
25
+ resolved_text = parts[0].strip()
26
+ mappings_text = parts[1].strip() if len(parts) > 1 else ""
27
+
28
+ entities = {}
29
+ for line in mappings_text.split("\n"):
30
+ line = line.strip()
31
+ if line.startswith("-"):
32
+ match = re.match(r'-\s*([^:]+):\s*\[([^\]]*)\]', line)
33
+ if match:
34
+ entity_name = match.group(1).strip()
35
+ variants = re.findall(r'"([^"]*)"', match.group(2))
36
+ if variants:
37
+ entities[entity_name] = variants
38
+ return resolved_text, entities
39
+ return response.strip(), {}
40
+
41
+
42
+ def format_entities_for_prompt(entities):
43
+ """Format known entities for the prompt."""
44
+ lines = ["Entities and their possible references:"]
45
+ for entity_name, variants in entities.items():
46
+ variants_str = ", ".join(f'"{v}"' for v in variants)
47
+ lines.append(f"- {entity_name}: [{variants_str}]")
48
+ return "\n".join(lines)
49
+
50
+
51
+ def load_model():
52
+ """Load the model and tokenizer."""
53
+ print(f"Loading {BASE_MODEL}...")
54
+ tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
55
+ model = AutoModelForCausalLM.from_pretrained(
56
+ BASE_MODEL,
57
+ torch_dtype=torch.bfloat16,
58
+ device_map="auto",
59
+ )
60
+ print(f"Loading adapter {MODEL_ID}...")
61
+ model = PeftModel.from_pretrained(model, MODEL_ID)
62
+ return model, tokenizer
63
+
64
+
65
+ def process_document(text, model, tokenizer, max_new_tokens=2048):
66
+ """Process document paragraph by paragraph with entity tracking."""
67
+ paragraphs = [p.strip() for p in text.split("\n\n") if p.strip()]
68
+ resolved_paragraphs = []
69
+ paragraph_entities = []
70
+ cumulative_entities = {}
71
+
72
+ for i, paragraph in enumerate(paragraphs):
73
+ print(f"Processing paragraph {i+1}/{len(paragraphs)}...")
74
+
75
+ # Build prompt
76
+ if i == 0:
77
+ prompt = f"Resolve all pronouns in this text, replacing them with the full entity names. Also identify any entity references you find.\n\n{paragraph}"
78
+ else:
79
+ context = "\n\n".join(resolved_paragraphs[max(0, i-2):i])
80
+ if cumulative_entities:
81
+ known_str = format_entities_for_prompt(cumulative_entities)
82
+ prompt = f"Known {known_str}\n\nGiven this context of preceding text (already resolved):\n\n{context}\n\nResolve all pronouns in this paragraph using the known entities. Also identify any NEW entity references:\n\n{paragraph}"
83
+ else:
84
+ prompt = f"Given this context of preceding text (already resolved):\n\n{context}\n\nResolve all pronouns in this paragraph. Also identify any NEW entity references:\n\n{paragraph}"
85
+
86
+ messages = [{"role": "user", "content": prompt}]
87
+ input_text = tokenizer.apply_chat_template(
88
+ messages, tokenize=False, add_generation_prompt=True, enable_thinking=False
89
+ )
90
+ inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
91
+
92
+ with torch.no_grad():
93
+ outputs = model.generate(
94
+ **inputs,
95
+ max_new_tokens=max_new_tokens,
96
+ do_sample=False,
97
+ pad_token_id=tokenizer.pad_token_id,
98
+ )
99
+
100
+ response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True).strip()
101
+
102
+ # Clean up
103
+ response = re.sub(r'<think>.*?</think>\s*', '', response, flags=re.DOTALL)
104
+
105
+ # Parse response
106
+ resolved, new_entities = parse_entity_mappings(response)
107
+ resolved_paragraphs.append(resolved)
108
+ paragraph_entities.append(new_entities)
109
+
110
+ # Update cumulative entities
111
+ for entity_name, variants in new_entities.items():
112
+ if entity_name not in cumulative_entities:
113
+ cumulative_entities[entity_name] = set()
114
+ cumulative_entities[entity_name].update(variants)
115
+
116
+ if new_entities:
117
+ print(f" New entities: {new_entities}")
118
+
119
+ # Convert sets to lists
120
+ cumulative_entities = {k: list(v) for k, v in cumulative_entities.items()}
121
+
122
+ return {
123
+ "paragraphs": paragraphs,
124
+ "resolved_paragraphs": resolved_paragraphs,
125
+ "paragraph_entities": paragraph_entities,
126
+ "cumulative_entities": cumulative_entities,
127
+ }
128
+
129
+
130
+ def main():
131
+ parser = argparse.ArgumentParser(description="Coreference Resolution")
132
+ parser.add_argument("input", help="Input text file")
133
+ parser.add_argument("-o", "--output", help="Output file for resolved text")
134
+ parser.add_argument("--max-tokens", type=int, default=2048, help="Max tokens to generate")
135
+ args = parser.parse_args()
136
+
137
+ # Load input
138
+ with open(args.input, "r") as f:
139
+ text = f.read().strip()
140
+
141
+ # Load model
142
+ model, tokenizer = load_model()
143
+
144
+ # Process
145
+ result = process_document(text, model, tokenizer, args.max_tokens)
146
+
147
+ # Output
148
+ resolved_text = "\n\n".join(result["resolved_paragraphs"])
149
+
150
+ print("\n" + "="*60)
151
+ print("RESOLVED TEXT:")
152
+ print("="*60)
153
+ print(resolved_text)
154
+
155
+ print("\n" + "="*60)
156
+ print("ENTITIES FOUND:")
157
+ print("="*60)
158
+ for entity, variants in result["cumulative_entities"].items():
159
+ print(f" {entity}: {variants}")
160
+
161
+ if args.output:
162
+ with open(args.output, "w") as f:
163
+ f.write(resolved_text)
164
+ print(f"\nSaved to {args.output}")
165
+
166
+
167
+ if __name__ == "__main__":
168
+ main()
optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:34357c2e564432b2cb4a560dd6b43843e1b736e4dc134193a1e1cebb5f215f96
3
+ size 5328249521
rng_state.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9e8573ad950caaf8d31c70708b6c77b84a02a0a6dfe1ba2103a628dbf8264866
3
+ size 14645
scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b5b940bf4670a51654bd371c9c5f586938ff842092e681c496849b0ebb572130
3
+ size 1465
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:be75606093db2094d7cd20f3c2f385c212750648bd6ea4fb2bf507a6a4c55506
3
+ size 11422650
tokenizer_config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "backend": "tokenizers",
4
+ "bos_token": null,
5
+ "clean_up_tokenization_spaces": false,
6
+ "eos_token": "<|im_end|>",
7
+ "errors": "replace",
8
+ "extra_special_tokens": [
9
+ "<|im_start|>",
10
+ "<|im_end|>",
11
+ "<|object_ref_start|>",
12
+ "<|object_ref_end|>",
13
+ "<|box_start|>",
14
+ "<|box_end|>",
15
+ "<|quad_start|>",
16
+ "<|quad_end|>",
17
+ "<|vision_start|>",
18
+ "<|vision_end|>",
19
+ "<|vision_pad|>",
20
+ "<|image_pad|>",
21
+ "<|video_pad|>"
22
+ ],
23
+ "is_local": false,
24
+ "model_max_length": 131072,
25
+ "pad_token": "<|endoftext|>",
26
+ "split_special_tokens": false,
27
+ "tokenizer_class": "Qwen2Tokenizer",
28
+ "unk_token": null
29
+ }
trainer_state.json ADDED
@@ -0,0 +1,684 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": null,
3
+ "best_metric": null,
4
+ "best_model_checkpoint": null,
5
+ "epoch": 1.6113796950539234,
6
+ "eval_steps": 500,
7
+ "global_step": 6500,
8
+ "is_hyper_param_search": false,
9
+ "is_local_process_zero": true,
10
+ "is_world_process_zero": true,
11
+ "log_history": [
12
+ {
13
+ "entropy": 0.9991093099117279,
14
+ "epoch": 0.024792363951902815,
15
+ "grad_norm": 0.7828091382980347,
16
+ "learning_rate": 0.00019800000000000002,
17
+ "loss": 1.2105257415771484,
18
+ "mean_token_accuracy": 0.7592608261108399,
19
+ "num_tokens": 428432.0,
20
+ "step": 100
21
+ },
22
+ {
23
+ "entropy": 0.4560545237362385,
24
+ "epoch": 0.04958472790380563,
25
+ "grad_norm": 0.6142551898956299,
26
+ "learning_rate": 0.00019996642557446167,
27
+ "loss": 0.4457200241088867,
28
+ "mean_token_accuracy": 0.9013872227072716,
29
+ "num_tokens": 860175.0,
30
+ "step": 200
31
+ },
32
+ {
33
+ "entropy": 0.2749050757288933,
34
+ "epoch": 0.07437709185570844,
35
+ "grad_norm": 0.5504621267318726,
36
+ "learning_rate": 0.0001998643654103928,
37
+ "loss": 0.26112810134887693,
38
+ "mean_token_accuracy": 0.9401605477929116,
39
+ "num_tokens": 1288393.0,
40
+ "step": 300
41
+ },
42
+ {
43
+ "entropy": 0.18620084561407566,
44
+ "epoch": 0.09916945580761126,
45
+ "grad_norm": 0.49035999178886414,
46
+ "learning_rate": 0.00019969388600561932,
47
+ "loss": 0.168951416015625,
48
+ "mean_token_accuracy": 0.9586734220385551,
49
+ "num_tokens": 1697950.0,
50
+ "step": 400
51
+ },
52
+ {
53
+ "entropy": 0.13362589346244932,
54
+ "epoch": 0.12396181975951406,
55
+ "grad_norm": 0.332853227853775,
56
+ "learning_rate": 0.00019945510415927565,
57
+ "loss": 0.1165453052520752,
58
+ "mean_token_accuracy": 0.9707631063461304,
59
+ "num_tokens": 2121801.0,
60
+ "step": 500
61
+ },
62
+ {
63
+ "entropy": 0.114101482629776,
64
+ "epoch": 0.14875418371141688,
65
+ "grad_norm": 0.25856056809425354,
66
+ "learning_rate": 0.00019914818346597883,
67
+ "loss": 0.09927322387695313,
68
+ "mean_token_accuracy": 0.9743164613842964,
69
+ "num_tokens": 2557586.0,
70
+ "step": 600
71
+ },
72
+ {
73
+ "entropy": 0.11320277975872159,
74
+ "epoch": 0.1735465476633197,
75
+ "grad_norm": 0.20196805894374847,
76
+ "learning_rate": 0.00019877333420374656,
77
+ "loss": 0.09849776268005371,
78
+ "mean_token_accuracy": 0.974927342236042,
79
+ "num_tokens": 2987323.0,
80
+ "step": 700
81
+ },
82
+ {
83
+ "entropy": 0.10322847299277782,
84
+ "epoch": 0.19833891161522252,
85
+ "grad_norm": 0.2440531700849533,
86
+ "learning_rate": 0.00019833081318993095,
87
+ "loss": 0.09059928894042969,
88
+ "mean_token_accuracy": 0.9767567777633667,
89
+ "num_tokens": 3409712.0,
90
+ "step": 800
91
+ },
92
+ {
93
+ "entropy": 0.09775902647525073,
94
+ "epoch": 0.22313127556712534,
95
+ "grad_norm": 0.3308379054069519,
96
+ "learning_rate": 0.00019782092360526762,
97
+ "loss": 0.08334708213806152,
98
+ "mean_token_accuracy": 0.9783057284355163,
99
+ "num_tokens": 3841892.0,
100
+ "step": 900
101
+ },
102
+ {
103
+ "entropy": 0.09744730332866311,
104
+ "epoch": 0.24792363951902813,
105
+ "grad_norm": 0.2839490473270416,
106
+ "learning_rate": 0.00019724401478615975,
107
+ "loss": 0.08426895141601562,
108
+ "mean_token_accuracy": 0.9779949200153351,
109
+ "num_tokens": 4270558.0,
110
+ "step": 1000
111
+ },
112
+ {
113
+ "entropy": 0.09355678971856833,
114
+ "epoch": 0.27271600347093095,
115
+ "grad_norm": 0.22099336981773376,
116
+ "learning_rate": 0.00019660048198534043,
117
+ "loss": 0.07872037887573242,
118
+ "mean_token_accuracy": 0.9789282914996147,
119
+ "num_tokens": 4692785.0,
120
+ "step": 1100
121
+ },
122
+ {
123
+ "entropy": 0.08774024970829487,
124
+ "epoch": 0.29750836742283376,
125
+ "grad_norm": 0.25038641691207886,
126
+ "learning_rate": 0.00019589076610107613,
127
+ "loss": 0.07532472610473633,
128
+ "mean_token_accuracy": 0.9797207751870155,
129
+ "num_tokens": 5123896.0,
130
+ "step": 1200
131
+ },
132
+ {
133
+ "entropy": 0.0822139031253755,
134
+ "epoch": 0.3223007313747366,
135
+ "grad_norm": 0.1757524311542511,
136
+ "learning_rate": 0.0001951153533750981,
137
+ "loss": 0.0712879753112793,
138
+ "mean_token_accuracy": 0.9809118565917015,
139
+ "num_tokens": 5558585.0,
140
+ "step": 1300
141
+ },
142
+ {
143
+ "entropy": 0.08247557899914681,
144
+ "epoch": 0.3470930953266394,
145
+ "grad_norm": 0.3174690902233124,
146
+ "learning_rate": 0.00019427477505946724,
147
+ "loss": 0.07155597686767579,
148
+ "mean_token_accuracy": 0.9806134033203125,
149
+ "num_tokens": 5993135.0,
150
+ "step": 1400
151
+ },
152
+ {
153
+ "entropy": 0.07734406786970795,
154
+ "epoch": 0.3718854592785422,
155
+ "grad_norm": 0.20085565745830536,
156
+ "learning_rate": 0.00019336960705260218,
157
+ "loss": 0.06758695125579833,
158
+ "mean_token_accuracy": 0.9812126770615578,
159
+ "num_tokens": 6422291.0,
160
+ "step": 1500
161
+ },
162
+ {
163
+ "entropy": 0.07385200836695731,
164
+ "epoch": 0.39667782323044504,
165
+ "grad_norm": 0.23364907503128052,
166
+ "learning_rate": 0.00019240046950471843,
167
+ "loss": 0.06287895202636719,
168
+ "mean_token_accuracy": 0.9826329717040062,
169
+ "num_tokens": 6859860.0,
170
+ "step": 1600
171
+ },
172
+ {
173
+ "entropy": 0.07059250806458295,
174
+ "epoch": 0.42147018718234786,
175
+ "grad_norm": 0.23875373601913452,
176
+ "learning_rate": 0.00019136802639295038,
177
+ "loss": 0.06304484367370605,
178
+ "mean_token_accuracy": 0.9824053046107292,
179
+ "num_tokens": 7290073.0,
180
+ "step": 1700
181
+ },
182
+ {
183
+ "entropy": 0.06737875854596495,
184
+ "epoch": 0.4462625511342507,
185
+ "grad_norm": 0.3208062946796417,
186
+ "learning_rate": 0.00019027298506644585,
187
+ "loss": 0.059958081245422366,
188
+ "mean_token_accuracy": 0.9828743213415145,
189
+ "num_tokens": 7725201.0,
190
+ "step": 1800
191
+ },
192
+ {
193
+ "entropy": 0.06706910256296396,
194
+ "epoch": 0.4710549150861535,
195
+ "grad_norm": 0.21684925258159637,
196
+ "learning_rate": 0.0001891160957617461,
197
+ "loss": 0.058564453125,
198
+ "mean_token_accuracy": 0.9831320327520371,
199
+ "num_tokens": 8158313.0,
200
+ "step": 1900
201
+ },
202
+ {
203
+ "entropy": 0.06947937468066812,
204
+ "epoch": 0.49584727903805625,
205
+ "grad_norm": 0.18770049512386322,
206
+ "learning_rate": 0.00018789815108878247,
207
+ "loss": 0.06172544956207275,
208
+ "mean_token_accuracy": 0.9823081752657891,
209
+ "num_tokens": 8578452.0,
210
+ "step": 2000
211
+ },
212
+ {
213
+ "entropy": 0.06397987404838204,
214
+ "epoch": 0.5206396429899591,
215
+ "grad_norm": 0.3015916347503662,
216
+ "learning_rate": 0.00018661998548784206,
217
+ "loss": 0.05666701316833496,
218
+ "mean_token_accuracy": 0.9837381663918495,
219
+ "num_tokens": 9008577.0,
220
+ "step": 2100
221
+ },
222
+ {
223
+ "entropy": 0.06192670753225684,
224
+ "epoch": 0.5454320069418619,
225
+ "grad_norm": 0.14773066341876984,
226
+ "learning_rate": 0.00018528247465787458,
227
+ "loss": 0.05475767612457275,
228
+ "mean_token_accuracy": 0.9839018094539642,
229
+ "num_tokens": 9442416.0,
230
+ "step": 2200
231
+ },
232
+ {
233
+ "entropy": 0.057383716171607375,
234
+ "epoch": 0.5702243708937648,
235
+ "grad_norm": 0.2786010503768921,
236
+ "learning_rate": 0.00018388653495653227,
237
+ "loss": 0.05079104423522949,
238
+ "mean_token_accuracy": 0.9851340425014495,
239
+ "num_tokens": 9866601.0,
240
+ "step": 2300
241
+ },
242
+ {
243
+ "entropy": 0.061573395412415265,
244
+ "epoch": 0.5950167348456675,
245
+ "grad_norm": 0.2154165506362915,
246
+ "learning_rate": 0.00018243312277235307,
247
+ "loss": 0.052988133430480956,
248
+ "mean_token_accuracy": 0.9846190690994263,
249
+ "num_tokens": 10287014.0,
250
+ "step": 2400
251
+ },
252
+ {
253
+ "entropy": 0.061048444965854286,
254
+ "epoch": 0.6198090987975704,
255
+ "grad_norm": 0.23032571375370026,
256
+ "learning_rate": 0.00018092323386951844,
257
+ "loss": 0.05165313720703125,
258
+ "mean_token_accuracy": 0.9843217238783837,
259
+ "num_tokens": 10717509.0,
260
+ "step": 2500
261
+ },
262
+ {
263
+ "entropy": 0.055967804118990896,
264
+ "epoch": 0.6446014627494732,
265
+ "grad_norm": 0.19078344106674194,
266
+ "learning_rate": 0.00017935790270563344,
267
+ "loss": 0.04785560607910156,
268
+ "mean_token_accuracy": 0.9853029519319534,
269
+ "num_tokens": 11157747.0,
270
+ "step": 2600
271
+ },
272
+ {
273
+ "entropy": 0.05705006473697722,
274
+ "epoch": 0.6693938267013759,
275
+ "grad_norm": 0.18230348825454712,
276
+ "learning_rate": 0.0001777382017229977,
277
+ "loss": 0.04942546844482422,
278
+ "mean_token_accuracy": 0.9849184802174569,
279
+ "num_tokens": 11593422.0,
280
+ "step": 2700
281
+ },
282
+ {
283
+ "entropy": 0.05708774453029036,
284
+ "epoch": 0.6941861906532788,
285
+ "grad_norm": 0.1923963725566864,
286
+ "learning_rate": 0.00017606524061385167,
287
+ "loss": 0.049316325187683106,
288
+ "mean_token_accuracy": 0.9849100703001022,
289
+ "num_tokens": 12015482.0,
290
+ "step": 2800
291
+ },
292
+ {
293
+ "entropy": 0.056122053125873206,
294
+ "epoch": 0.7189785546051816,
295
+ "grad_norm": 0.13828027248382568,
296
+ "learning_rate": 0.00017434016556010264,
297
+ "loss": 0.048600535392761234,
298
+ "mean_token_accuracy": 0.9853047552704811,
299
+ "num_tokens": 12444156.0,
300
+ "step": 2900
301
+ },
302
+ {
303
+ "entropy": 0.051999541874974964,
304
+ "epoch": 0.7437709185570844,
305
+ "grad_norm": 0.24286241829395294,
306
+ "learning_rate": 0.00017256415844805063,
307
+ "loss": 0.04440320014953613,
308
+ "mean_token_accuracy": 0.9864806136488915,
309
+ "num_tokens": 12876720.0,
310
+ "step": 3000
311
+ },
312
+ {
313
+ "entropy": 0.04768232893198729,
314
+ "epoch": 0.7685632825089872,
315
+ "grad_norm": 0.1362326294183731,
316
+ "learning_rate": 0.00017073843605865243,
317
+ "loss": 0.042284860610961914,
318
+ "mean_token_accuracy": 0.9867907965183258,
319
+ "num_tokens": 13316689.0,
320
+ "step": 3100
321
+ },
322
+ {
323
+ "entropy": 0.05134817799553275,
324
+ "epoch": 0.7933556464608901,
325
+ "grad_norm": 0.1539483368396759,
326
+ "learning_rate": 0.00016886424923387859,
327
+ "loss": 0.04517318725585937,
328
+ "mean_token_accuracy": 0.9861972403526306,
329
+ "num_tokens": 13745299.0,
330
+ "step": 3200
331
+ },
332
+ {
333
+ "entropy": 0.051489096255972984,
334
+ "epoch": 0.8181480104127928,
335
+ "grad_norm": 0.14677491784095764,
336
+ "learning_rate": 0.00016694288201973457,
337
+ "loss": 0.04445661067962647,
338
+ "mean_token_accuracy": 0.9860166025161743,
339
+ "num_tokens": 14174424.0,
340
+ "step": 3300
341
+ },
342
+ {
343
+ "entropy": 0.04676903900690377,
344
+ "epoch": 0.8429403743646957,
345
+ "grad_norm": 0.21468833088874817,
346
+ "learning_rate": 0.0001649756507865328,
347
+ "loss": 0.041012239456176755,
348
+ "mean_token_accuracy": 0.987050573527813,
349
+ "num_tokens": 14611781.0,
350
+ "step": 3400
351
+ },
352
+ {
353
+ "entropy": 0.0482857808098197,
354
+ "epoch": 0.8677327383165985,
355
+ "grad_norm": 0.14730653166770935,
356
+ "learning_rate": 0.00016296390332701924,
357
+ "loss": 0.04293826103210449,
358
+ "mean_token_accuracy": 0.9866457509994507,
359
+ "num_tokens": 15038473.0,
360
+ "step": 3500
361
+ },
362
+ {
363
+ "entropy": 0.04790851186960936,
364
+ "epoch": 0.8925251022685013,
365
+ "grad_norm": 0.2903175950050354,
366
+ "learning_rate": 0.0001609090179329709,
367
+ "loss": 0.041955056190490725,
368
+ "mean_token_accuracy": 0.9864692252874374,
369
+ "num_tokens": 15470046.0,
370
+ "step": 3600
371
+ },
372
+ {
373
+ "entropy": 0.048887748084962365,
374
+ "epoch": 0.9173174662204041,
375
+ "grad_norm": 0.18117748200893402,
376
+ "learning_rate": 0.0001588124024508986,
377
+ "loss": 0.04415608406066895,
378
+ "mean_token_accuracy": 0.985989620089531,
379
+ "num_tokens": 15892623.0,
380
+ "step": 3700
381
+ },
382
+ {
383
+ "entropy": 0.04632032319903374,
384
+ "epoch": 0.942109830172307,
385
+ "grad_norm": 0.16654178500175476,
386
+ "learning_rate": 0.00015667549331750067,
387
+ "loss": 0.042152628898620606,
388
+ "mean_token_accuracy": 0.9865523239970208,
389
+ "num_tokens": 16316100.0,
390
+ "step": 3800
391
+ },
392
+ {
393
+ "entropy": 0.044644428994506595,
394
+ "epoch": 0.9669021941242097,
395
+ "grad_norm": 0.2481166422367096,
396
+ "learning_rate": 0.0001544997545755291,
397
+ "loss": 0.04001152038574219,
398
+ "mean_token_accuracy": 0.9875221633911133,
399
+ "num_tokens": 16747053.0,
400
+ "step": 3900
401
+ },
402
+ {
403
+ "entropy": 0.04754056423902511,
404
+ "epoch": 0.9916945580761125,
405
+ "grad_norm": 0.12741857767105103,
406
+ "learning_rate": 0.00015228667687074214,
407
+ "loss": 0.04207493782043457,
408
+ "mean_token_accuracy": 0.9866985288262368,
409
+ "num_tokens": 17169662.0,
410
+ "step": 4000
411
+ },
412
+ {
413
+ "entropy": 0.04459555751302434,
414
+ "epoch": 1.0163629602082558,
415
+ "grad_norm": 0.09805303066968918,
416
+ "learning_rate": 0.00015003777643063054,
417
+ "loss": 0.03870807647705078,
418
+ "mean_token_accuracy": 0.9877826987798489,
419
+ "num_tokens": 17596478.0,
420
+ "step": 4100
421
+ },
422
+ {
423
+ "entropy": 0.0423293265234679,
424
+ "epoch": 1.0411553241601588,
425
+ "grad_norm": 0.15998226404190063,
426
+ "learning_rate": 0.0001477545940256172,
427
+ "loss": 0.03742676258087158,
428
+ "mean_token_accuracy": 0.9879223209619522,
429
+ "num_tokens": 18017906.0,
430
+ "step": 4200
431
+ },
432
+ {
433
+ "entropy": 0.03891188260167837,
434
+ "epoch": 1.0659476881120615,
435
+ "grad_norm": 0.1506214290857315,
436
+ "learning_rate": 0.00014543869391344224,
437
+ "loss": 0.03518922805786133,
438
+ "mean_token_accuracy": 0.9887040394544602,
439
+ "num_tokens": 18454216.0,
440
+ "step": 4300
441
+ },
442
+ {
443
+ "entropy": 0.04142872649244964,
444
+ "epoch": 1.0907400520639643,
445
+ "grad_norm": 0.1666085124015808,
446
+ "learning_rate": 0.00014309166276745564,
447
+ "loss": 0.03670289039611816,
448
+ "mean_token_accuracy": 0.9879066833853721,
449
+ "num_tokens": 18878519.0,
450
+ "step": 4400
451
+ },
452
+ {
453
+ "entropy": 0.03755377263762057,
454
+ "epoch": 1.115532416015867,
455
+ "grad_norm": 0.2086615115404129,
456
+ "learning_rate": 0.00014071510858955336,
457
+ "loss": 0.03333067655563354,
458
+ "mean_token_accuracy": 0.989110766351223,
459
+ "num_tokens": 19317824.0,
460
+ "step": 4500
461
+ },
462
+ {
463
+ "entropy": 0.04046432740055025,
464
+ "epoch": 1.14032477996777,
465
+ "grad_norm": 0.20940445363521576,
466
+ "learning_rate": 0.00013831065960850038,
467
+ "loss": 0.03586224794387818,
468
+ "mean_token_accuracy": 0.9884641316533088,
469
+ "num_tokens": 19745984.0,
470
+ "step": 4600
471
+ },
472
+ {
473
+ "entropy": 0.03863211246207356,
474
+ "epoch": 1.1651171439196728,
475
+ "grad_norm": 0.1907690167427063,
476
+ "learning_rate": 0.0001358799631643955,
477
+ "loss": 0.03435335397720337,
478
+ "mean_token_accuracy": 0.9888206848502159,
479
+ "num_tokens": 20180245.0,
480
+ "step": 4700
481
+ },
482
+ {
483
+ "entropy": 0.04046371933072805,
484
+ "epoch": 1.1899095078715756,
485
+ "grad_norm": 0.13110345602035522,
486
+ "learning_rate": 0.00013342468458004347,
487
+ "loss": 0.03644887685775757,
488
+ "mean_token_accuracy": 0.9881230041384697,
489
+ "num_tokens": 20606265.0,
490
+ "step": 4800
491
+ },
492
+ {
493
+ "entropy": 0.03736146904528141,
494
+ "epoch": 1.2147018718234783,
495
+ "grad_norm": 0.1462518870830536,
496
+ "learning_rate": 0.00013094650602000582,
497
+ "loss": 0.03372693538665771,
498
+ "mean_token_accuracy": 0.9891441905498505,
499
+ "num_tokens": 21044494.0,
500
+ "step": 4900
501
+ },
502
+ {
503
+ "entropy": 0.03839201644994319,
504
+ "epoch": 1.239494235775381,
505
+ "grad_norm": 0.11341901123523712,
506
+ "learning_rate": 0.00012844712533811376,
507
+ "loss": 0.03437334060668945,
508
+ "mean_token_accuracy": 0.9888800847530365,
509
+ "num_tokens": 21480042.0,
510
+ "step": 5000
511
+ },
512
+ {
513
+ "entropy": 0.037934175664559006,
514
+ "epoch": 1.264286599727284,
515
+ "grad_norm": 0.23413598537445068,
516
+ "learning_rate": 0.0001259282549142315,
517
+ "loss": 0.03376242399215698,
518
+ "mean_token_accuracy": 0.9890937665104866,
519
+ "num_tokens": 21912071.0,
520
+ "step": 5100
521
+ },
522
+ {
523
+ "entropy": 0.03757761628367007,
524
+ "epoch": 1.2890789636791868,
525
+ "grad_norm": 0.14774999022483826,
526
+ "learning_rate": 0.0001233916204810679,
527
+ "loss": 0.03416965961456299,
528
+ "mean_token_accuracy": 0.9889910009503364,
529
+ "num_tokens": 22335448.0,
530
+ "step": 5200
531
+ },
532
+ {
533
+ "entropy": 0.03822989201173186,
534
+ "epoch": 1.3138713276310896,
535
+ "grad_norm": 0.11656388640403748,
536
+ "learning_rate": 0.00012083895994183948,
537
+ "loss": 0.03509602785110474,
538
+ "mean_token_accuracy": 0.9885432028770447,
539
+ "num_tokens": 22756521.0,
540
+ "step": 5300
541
+ },
542
+ {
543
+ "entropy": 0.03775340311229229,
544
+ "epoch": 1.3386636915829924,
545
+ "grad_norm": 0.1481839120388031,
546
+ "learning_rate": 0.00011827202217959523,
547
+ "loss": 0.0340172815322876,
548
+ "mean_token_accuracy": 0.9888760358095169,
549
+ "num_tokens": 23181534.0,
550
+ "step": 5400
551
+ },
552
+ {
553
+ "entropy": 0.03720983518287539,
554
+ "epoch": 1.3634560555348951,
555
+ "grad_norm": 0.13698537647724152,
556
+ "learning_rate": 0.00011569256585901918,
557
+ "loss": 0.03371585130691528,
558
+ "mean_token_accuracy": 0.9890251788496971,
559
+ "num_tokens": 23613467.0,
560
+ "step": 5500
561
+ },
562
+ {
563
+ "entropy": 0.037667012261226776,
564
+ "epoch": 1.3882484194867981,
565
+ "grad_norm": 0.09335887432098389,
566
+ "learning_rate": 0.00011310235822153073,
567
+ "loss": 0.03394256591796875,
568
+ "mean_token_accuracy": 0.9890615126490593,
569
+ "num_tokens": 24039912.0,
570
+ "step": 5600
571
+ },
572
+ {
573
+ "entropy": 0.03788006491959095,
574
+ "epoch": 1.4130407834387009,
575
+ "grad_norm": 0.1678655594587326,
576
+ "learning_rate": 0.0001105031738745096,
577
+ "loss": 0.034035165309906,
578
+ "mean_token_accuracy": 0.9887340119481087,
579
+ "num_tokens": 24464996.0,
580
+ "step": 5700
581
+ },
582
+ {
583
+ "entropy": 0.03637797945179045,
584
+ "epoch": 1.4378331473906036,
585
+ "grad_norm": 0.17894072830677032,
586
+ "learning_rate": 0.00010789679357547364,
587
+ "loss": 0.03286903142929077,
588
+ "mean_token_accuracy": 0.9891549465060234,
589
+ "num_tokens": 24901092.0,
590
+ "step": 5800
591
+ },
592
+ {
593
+ "entropy": 0.03953015809878707,
594
+ "epoch": 1.4626255113425066,
595
+ "grad_norm": 0.1642547845840454,
596
+ "learning_rate": 0.00010528500301204345,
597
+ "loss": 0.03447899341583252,
598
+ "mean_token_accuracy": 0.988511001765728,
599
+ "num_tokens": 25320711.0,
600
+ "step": 5900
601
+ },
602
+ {
603
+ "entropy": 0.03696547055616975,
604
+ "epoch": 1.4874178752944094,
605
+ "grad_norm": 0.15598466992378235,
606
+ "learning_rate": 0.0001026695915785289,
607
+ "loss": 0.03327722549438476,
608
+ "mean_token_accuracy": 0.9893461042642593,
609
+ "num_tokens": 25750634.0,
610
+ "step": 6000
611
+ },
612
+ {
613
+ "entropy": 0.03747725712135434,
614
+ "epoch": 1.5122102392463121,
615
+ "grad_norm": 0.09570539742708206,
616
+ "learning_rate": 0.00010005235114997651,
617
+ "loss": 0.03426354885101318,
618
+ "mean_token_accuracy": 0.9889142262935638,
619
+ "num_tokens": 26175757.0,
620
+ "step": 6100
621
+ },
622
+ {
623
+ "entropy": 0.037917951373383406,
624
+ "epoch": 1.537002603198215,
625
+ "grad_norm": 0.2064983993768692,
626
+ "learning_rate": 9.743507485451688e-05,
627
+ "loss": 0.03446398973464966,
628
+ "mean_token_accuracy": 0.9886316114664078,
629
+ "num_tokens": 26601186.0,
630
+ "step": 6200
631
+ },
632
+ {
633
+ "entropy": 0.037627564212307334,
634
+ "epoch": 1.5617949671501177,
635
+ "grad_norm": 0.17442478239536285,
636
+ "learning_rate": 9.48195558448538e-05,
637
+ "loss": 0.0337642502784729,
638
+ "mean_token_accuracy": 0.988581260740757,
639
+ "num_tokens": 27028439.0,
640
+ "step": 6300
641
+ },
642
+ {
643
+ "entropy": 0.035229697693139314,
644
+ "epoch": 1.5865873311020207,
645
+ "grad_norm": 0.19224514067173004,
646
+ "learning_rate": 9.220758606973652e-05,
647
+ "loss": 0.03189241409301758,
648
+ "mean_token_accuracy": 0.989690189063549,
649
+ "num_tokens": 27461882.0,
650
+ "step": 6400
651
+ },
652
+ {
653
+ "entropy": 0.035260174684226514,
654
+ "epoch": 1.6113796950539234,
655
+ "grad_norm": 0.11715493351221085,
656
+ "learning_rate": 8.960095504625676e-05,
657
+ "loss": 0.032297356128692625,
658
+ "mean_token_accuracy": 0.9895079037547112,
659
+ "num_tokens": 27898972.0,
660
+ "step": 6500
661
+ }
662
+ ],
663
+ "logging_steps": 100,
664
+ "max_steps": 12102,
665
+ "num_input_tokens_seen": 0,
666
+ "num_train_epochs": 3,
667
+ "save_steps": 500,
668
+ "stateful_callbacks": {
669
+ "TrainerControl": {
670
+ "args": {
671
+ "should_epoch_stop": false,
672
+ "should_evaluate": false,
673
+ "should_log": false,
674
+ "should_save": true,
675
+ "should_training_stop": false
676
+ },
677
+ "attributes": {}
678
+ }
679
+ },
680
+ "total_flos": 1.8627923803091927e+18,
681
+ "train_batch_size": 4,
682
+ "trial_name": null,
683
+ "trial_params": null
684
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:37d8efe0593d9b11bf440e19ce9e027f4c1a8f145ce1ea5ceedafeb64107093d
3
+ size 5585