Safetensors
qwen2
tim-essential commited on
Commit
fa45741
Β·
1 Parent(s): ac4589c

Restore README.md

Browse files
Files changed (1) hide show
  1. README.md +97 -87
README.md CHANGED
@@ -1,110 +1,120 @@
1
  ---
2
  license: apache-2.0
3
- license_link: https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct/blob/main/LICENSE
4
- language:
5
- - en
6
- pipeline_tag: text-generation
7
- base_model: Qwen/Qwen2.5-0.5B
8
- tags:
9
- - chat
10
- library_name: transformers
11
  ---
 
12
 
13
- # Qwen2.5-0.5B-Instruct
14
 
15
- ## Introduction
16
 
17
- Qwen2.5 is the latest series of Qwen large language models. For Qwen2.5, we release a number of base language models and instruction-tuned language models ranging from 0.5 to 72 billion parameters. Qwen2.5 brings the following improvements upon Qwen2:
 
 
 
 
 
18
 
19
- - Significantly **more knowledge** and has greatly improved capabilities in **coding** and **mathematics**, thanks to our specialized expert models in these domains.
20
- - Significant improvements in **instruction following**, **generating long texts** (over 8K tokens), **understanding structured data** (e.g, tables), and **generating structured outputs** especially JSON. **More resilient to the diversity of system prompts**, enhancing role-play implementation and condition-setting for chatbots.
21
- - **Long-context Support** up to 128K tokens and can generate up to 8K tokens.
22
- - **Multilingual support** for over 29 languages, including Chinese, English, French, Spanish, Portuguese, German, Italian, Russian, Japanese, Korean, Vietnamese, Thai, Arabic, and more.
23
 
24
- **This repo contains the instruction-tuned 0.5B Qwen2.5 model**, which has the following features:
25
- - Type: Causal Language Models
26
- - Training Stage: Pretraining & Post-training
27
- - Architecture: transformers with RoPE, SwiGLU, RMSNorm, Attention QKV bias and tied word embeddings
28
- - Number of Parameters: 0.49B
29
- - Number of Paramaters (Non-Embedding): 0.36B
30
- - Number of Layers: 24
31
- - Number of Attention Heads (GQA): 14 for Q and 2 for KV
32
- - Context Length: Full 32,768 tokens and generation 8192 tokens
33
 
34
- For more details, please refer to our [blog](https://qwenlm.github.io/blog/qwen2.5/), [GitHub](https://github.com/QwenLM/Qwen2.5), and [Documentation](https://qwen.readthedocs.io/en/latest/).
35
 
36
- ## Requirements
37
-
38
- The code of Qwen2.5 has been in the latest Hugging face `transformers` and we advise you to use the latest version of `transformers`.
39
-
40
- With `transformers<4.37.0`, you will encounter the following error:
41
- ```
42
- KeyError: 'qwen2'
43
- ```
44
-
45
- ## Quickstart
46
-
47
- Here provides a code snippet with `apply_chat_template` to show you how to load the tokenizer and model and how to generate contents.
48
 
49
  ```python
50
- from transformers import AutoModelForCausalLM, AutoTokenizer
51
-
52
- model_name = "Qwen/Qwen2.5-0.5B-Instruct"
53
-
54
- model = AutoModelForCausalLM.from_pretrained(
55
- model_name,
56
- torch_dtype="auto",
57
- device_map="auto"
58
- )
59
- tokenizer = AutoTokenizer.from_pretrained(model_name)
60
-
61
- prompt = "Give me a short introduction to large language model."
62
- messages = [
63
- {"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
64
- {"role": "user", "content": prompt}
65
- ]
66
- text = tokenizer.apply_chat_template(
67
- messages,
68
- tokenize=False,
69
- add_generation_prompt=True
70
- )
71
- model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
72
-
73
- generated_ids = model.generate(
74
- **model_inputs,
75
- max_new_tokens=512
76
- )
77
- generated_ids = [
78
- output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
79
- ]
80
-
81
- response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  ```
83
 
 
84
 
85
- ## Evaluation & Performance
 
 
 
 
 
 
 
 
 
 
 
 
86
 
87
- Detailed evaluation results are reported in this [πŸ“‘ blog](https://qwenlm.github.io/blog/qwen2.5/).
88
 
89
- For requirements on GPU memory and the respective throughput, see results [here](https://qwen.readthedocs.io/en/latest/benchmark/speed_benchmark.html).
 
 
 
 
90
 
91
- ## Citation
92
 
93
- If you find our work helpful, feel free to give us a cite.
 
 
 
94
 
95
- ```
96
- @misc{qwen2.5,
97
- title = {Qwen2.5: A Party of Foundation Models},
98
- url = {https://qwenlm.github.io/blog/qwen2.5/},
99
- author = {Qwen Team},
100
- month = {September},
101
- year = {2024}
102
- }
103
 
104
- @article{qwen2,
105
- title={Qwen2 Technical Report},
106
- author={An Yang and Baosong Yang and Binyuan Hui and Bo Zheng and Bowen Yu and Chang Zhou and Chengpeng Li and Chengyuan Li and Dayiheng Liu and Fei Huang and Guanting Dong and Haoran Wei and Huan Lin and Jialong Tang and Jialin Wang and Jian Yang and Jianhong Tu and Jianwei Zhang and Jianxin Ma and Jin Xu and Jingren Zhou and Jinze Bai and Jinzheng He and Junyang Lin and Kai Dang and Keming Lu and Keqin Chen and Kexin Yang and Mei Li and Mingfeng Xue and Na Ni and Pei Zhang and Peng Wang and Ru Peng and Rui Men and Ruize Gao and Runji Lin and Shijie Wang and Shuai Bai and Sinan Tan and Tianhang Zhu and Tianhao Li and Tianyu Liu and Wenbin Ge and Xiaodong Deng and Xiaohuan Zhou and Xingzhang Ren and Xinyu Zhang and Xipin Wei and Xuancheng Ren and Yang Fan and Yang Yao and Yichang Zhang and Yu Wan and Yunfei Chu and Yuqiong Liu and Zeyu Cui and Zhenru Zhang and Zhihao Fan},
107
- journal={arXiv preprint arXiv:2407.10671},
108
- year={2024}
 
109
  }
110
  ```
 
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
 
 
3
  ---
4
+ # 🏷️ EAI-Distill-0.5b
5
 
6
+ ## πŸ“‹ Model Description
7
 
8
+ EAI-Distill-0.5b is a fine-tuned version of Qwen2.5-0.5B-Instruct designed for document classification across 12 taxonomic categories. This model is optimized for high-throughput classification of web documents and produces structured metadata for large-scale dataset curation.
9
 
10
+ The model classifies documents across the following dimensions:
11
+ - **πŸ“š Free Decimal Correspondence (FDC)**: Subject matter classification based on the Dewey Decimal System
12
+ - **🧠 Bloom's Taxonomy**: Cognitive process (Remember/Understand/Apply/Analyze/Evaluate/Create) and knowledge domain (Factual/Conceptual/Procedural/Metacognitive)
13
+ - **πŸ“„ Document Type**: Web page categorization (News, Academic, Reference, Code, Social, etc.)
14
+ - **πŸ” Content Quality**: Extraction artifacts, missing content detection
15
+ - **πŸŽ“ Educational Metadata**: Reasoning depth, technical correctness, educational level
16
 
17
+ ## πŸš€ Training Details
 
 
 
18
 
19
+ - **πŸ€– Base Model**: Qwen2.5-0.5B-Instruct
20
+ - **πŸ“Š Training Data**: 82B synthetic tokens generated by Qwen2.5-32B-Instruct (teacher model) on 104M Common Crawl documents
21
+ - **βš™οΈ Optimizer**: AdamW (β₁=0.9, Ξ²β‚‚=0.95, weight_decay=0.1)
22
+ - **πŸ“ˆ Learning Rate**: 1Γ—10⁻⁴ with linear warmup (2B tokens), cosine decay to 1Γ—10⁻⁡, then linear anneal to 0
23
+ - **πŸ“¦ Batch Size**: 2M tokens
24
+ - **πŸ“ Sequence Length**: 16,384 tokens
25
+ - **πŸ’» Hardware**: Trained on AMD MI300x GPUs
 
 
26
 
27
+ ## πŸ“Š Performance
28
 
29
+ The model achieves an average Cohen's ΞΊ agreement of 0.71-0.74 with our golden annotators, GPT-4o and Claude 3.5 Sonnet, on held-out evaluation sets, which is within 3% of its teacher model Qwen2.5-32b-Instruct while being 64Γ— smaller.
30
+ ## πŸ’» Usage
 
 
 
 
 
 
 
 
 
 
31
 
32
  ```python
33
+ from transformers import AutoTokenizer, AutoModelForCausalLM
34
+ import random
35
+
36
+ # Load model and tokenizer
37
+ tokenizer = AutoTokenizer.from_pretrained("EssentialAI/EAI-Distill-0.5b", trust_remote_code=True)
38
+ model = AutoModelForCausalLM.from_pretrained("EssentialAI/EAI-Distill-0.5b")
39
+
40
+ def chunk_text(text, max_char_per_doc=30000):
41
+ if len(text) <= max_char_per_doc:
42
+ return text
43
+
44
+ chunk_size = max_char_per_doc // 3
45
+ start = text[:chunk_size]
46
+
47
+ middle_start = chunk_size
48
+ middle_end = len(text) - chunk_size
49
+
50
+ mid_point = random.randint(middle_start + chunk_size//2, middle_end - chunk_size//2)
51
+
52
+ middle = text[mid_point - chunk_size//2:mid_point + chunk_size//2]
53
+ end = text[-chunk_size:]
54
+ return f"[beginning]\n{start}\n[middle]\n{middle}\n[end]\n{end}"
55
+
56
+ def classify_document(text):
57
+ chunked_text = chunk_text(text)
58
+
59
+ messages = [
60
+ {"role": "system", "content": "taxonomy"},
61
+ {"role": "user", "content": chunked_text},
62
+ ]
63
+
64
+ prompt = tokenizer.apply_chat_template(
65
+ messages,
66
+ tokenize=False,
67
+ add_generation_prompt=True
68
+ )
69
+
70
+ inputs = tokenizer(prompt, return_tensors="pt")
71
+ outputs = model.generate(**inputs, max_new_tokens=100)
72
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
73
+
74
+ # Example usage
75
+ document_text = "Your document content here..."
76
+ classification = classify_document(document_text)
77
+ print(classification)
78
  ```
79
 
80
+ ## πŸ“€ Output Format
81
 
82
+ The model outputs classifications in a condensed format:
83
+ ```
84
+ {FDC primary},{FDC secondary or skip}
85
+ {Bloom cognitive process primary (1-6)},{Bloom cognitive process secondary (1-6) or skip}
86
+ {Bloom knowledge domain primary (1-4)},{Bloom knowledge domain secondary (1-4) or skip}
87
+ {Document type v1 primary (1-17)},{Document type v1 secondary (1-17) or skip}
88
+ {Extraction artifacts primary (0-4)},{Extraction artifacts secondary (0-4) or skip}
89
+ {Missing content primary (0-6)},{Missing content secondary (0-6) or skip}
90
+ {Document type v2 primary (1-25)},{Document type v2 secondary (1-25) or skip}
91
+ {Reasoning depth primary (1-6)},{Reasoning depth secondary (1-6) or skip}
92
+ {Technical correctness primary (1-6)},{Technical correctness secondary (1-6) or skip}
93
+ {Educational level primary (1-5)},{Educational level secondary (1-5) or skip}
94
+ ```
95
 
96
+ ## 🎯 Intended Use
97
 
98
+ This model is designed for:
99
+ - πŸ—οΈ Large-scale web document classification and metadata generation
100
+ - πŸ”§ Dataset curation through taxonomic filtering
101
+ - βœ… Content quality assessment for training data preparation
102
+ - πŸ“š Educational content analysis and organization
103
 
104
+ ## ⚠️ Limitations
105
 
106
+ - Optimized for English web documents extracted using resiliparse
107
+ - Documents over 30k characters are automatically chunked, which may affect classification accuracy
108
+ - Performance may vary on content significantly different from Common Crawl web data
109
+ - Classification categories are based on web content patterns and may not generalize to other document types
110
 
111
+ ## πŸ“ Citation
 
 
 
 
 
 
 
112
 
113
+ If you use this model, please cite:
114
+ ```bibtex
115
+ @article{essential-web-2024,
116
+ title={Essential-Web: A 24-Trillion Token Dataset with Extensive Metadata for Training LLMs},
117
+ author={[Your Authors]},
118
+ year={2024}
119
  }
120
  ```