File size: 4,696 Bytes
9120fea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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
---
license: cc-by-nc-4.0
base_model: Qwen/Qwen3-1.7B-Base
tags:
  - continued-pretraining
  - cpt
  - domain-adaptation
  - llm
  - transformers
  - educational
language:
  - en
library_name: transformers
pipeline_tag: text-generation
---

# cpt-v2 — Domain-Adapted Qwen3-1.7B (Continued Pretraining)

> **⚠️ Educational project.** This model is a personal learning experiment,
> released **for learning and educational purposes only**. See
> [License & Intended Use](#license--intended-use).

`cpt-v2` is [Qwen/Qwen3-1.7B-Base](https://huggingface.co/Qwen/Qwen3-1.7B-Base)
after **continued pretraining (CPT)** on a curated corpus of LLM /
neural-network / transformer material. The goal is to shift the base model
toward the machine-learning domain before instruction tuning (SFT) and
preference tuning (DPO) in later stages.

This is **stage 1 of 3** in a small end-to-end pipeline:

```
Qwen3-1.7B-Base  ──CPT──▶  cpt-v2  ──SFT──▶  sft-v1  ──DPO──▶  dpo-v1
                          (this repo)
```

---

## What it is

- **Base model:** Qwen/Qwen3-1.7B-Base (Apache-2.0)
- **Method:** Full fine-tuning (continued pretraining), bfloat16
- **Domain:** Large language models, neural networks, transformers, deep learning
- **Purpose:** A learning project demonstrating a realistic, quality-controlled
  domain-adaptation pipeline.

## Results (held-out perplexity, lower = better)

| Model | Domain PPL | General PPL |
|---|---|---|
| Qwen3-1.7B-Base | 5.87 | 10.23 |
| **cpt-v2** | **5.29** | 10.57 |
| Change | **−9.9%** (specialized ✅) | +3.3% (mild) |

Domain perplexity dropped ~10% (the model specialized on ML/NN/transformer
text), while general perplexity rose only slightly — a general-text replay
mix kept catastrophic forgetting mild.

## Training summary

| Item | Value |
|---|---|
| Base | Qwen/Qwen3-1.7B-Base |
| Training type | Full fine-tuning (continued pretraining) |
| Precision | bfloat16 |
| Block size | 2048 tokens |
| Epochs | 1 |
| Learning rate | 1e-4, cosine schedule |
| Anti-forgetting | general-text replay mixed into training |

> The training corpus was assembled from publicly available material for
> **personal, educational training use only**, and is **not** included or
> redistributed here. This repository contains only the resulting model weights.

## Intended use

- Studying how continued pretraining shifts a base model toward a domain.
- A starting point for the SFT stage.
- Educational demos comparing base vs. domain-adapted behavior.

## How to use

> This is a **base-style** (not instruction-tuned) model. It gives coherent
> domain answers on completion-style prompts, but does not yet follow
> instructions or stop cleanly — that's what the later SFT/DPO stages add.

```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

tok = AutoTokenizer.from_pretrained("vinmlops/cpt-v2")
model = AutoModelForCausalLM.from_pretrained("vinmlops/cpt-v2", dtype=torch.bfloat16)

prompt = "Attention in a transformer is"
inputs = tok(prompt, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=128, do_sample=False)
print(tok.decode(out[0], skip_special_tokens=True))
```


## Limitations

- **Small-scale, experimental.** A genuine but modest domain shift, not deep
  expertise.
- **Base-style model.** It continues text; it is not tuned to follow
  instructions or hold a conversation (that's the SFT/DPO stages). On
  instruction-style prompts it may ramble or repeat — expected for a base model.
- **May produce inaccurate or outdated information.** Do not rely on it for
  factual, production, or critical use.
- Inherits any biases and limitations of the base model and training data.

## License & Intended Use

**This model is released for learning and educational purposes only.**

- Licensed under **CC-BY-NC-4.0** (Creative Commons Attribution–NonCommercial 4.0).
- You may use, study, and share it for **non-commercial, educational, and
  research purposes**, with attribution.
- **Commercial use is not permitted.**
- Provided **"as is", without warranty** of any kind; it may produce inaccurate
  output. Use at your own risk.
- **Base model:** [Qwen/Qwen3-1.7B-Base](https://huggingface.co/Qwen/Qwen3-1.7B-Base)
  (Apache-2.0). This derivative adds continued pretraining for personal
  educational use. Please also respect the base model's license.

## Citation / attribution

If you reference this educational project:

```
vinmlops/cpt-v2 — domain-adapted Qwen3-1.7B (continued pretraining),
an educational LLM/NN/transformer learning project. Non-commercial (CC-BY-NC-4.0).
Base model: Qwen/Qwen3-1.7B-Base (Apache-2.0).
```