Commit
Β·
fa45741
1
Parent(s):
ac4589c
Restore README.md
Browse files
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 |
-
|
| 14 |
|
| 15 |
-
|
| 16 |
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
| 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 |
-
|
| 25 |
-
-
|
| 26 |
-
-
|
| 27 |
-
-
|
| 28 |
-
-
|
| 29 |
-
-
|
| 30 |
-
-
|
| 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 |
-
|
| 35 |
|
| 36 |
-
|
| 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
|
| 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 |
-
@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 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
|
|
|
| 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 |
```
|