Update README.md
Browse files
README.md
CHANGED
|
@@ -1,205 +1,170 @@
|
|
| 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 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
publisher = {Hugging Face},
|
| 172 |
-
url = {https://huggingface.co/alexanderquispe/naics-github-classifier}
|
| 173 |
-
}
|
| 174 |
-
|
| 175 |
-
Repository
|
| 176 |
-
|
| 177 |
-
Training code and data preparation: https://github.com/alexanderquispe/naics-github-train
|
| 178 |
-
|
| 179 |
-
---
|
| 180 |
-
|
| 181 |
-
**To upload:**
|
| 182 |
-
|
| 183 |
-
1. Go to https://huggingface.co/alexanderquispe/naics-github-classifier
|
| 184 |
-
2. Click the **"Files and versions"** tab
|
| 185 |
-
3. Click **"Edit"** on `README.md` (or create it)
|
| 186 |
-
4. Paste the content above
|
| 187 |
-
5. Click **"Commit changes"**
|
| 188 |
-
|
| 189 |
-
Or from Colab:
|
| 190 |
-
|
| 191 |
-
```python
|
| 192 |
-
from huggingface_hub import upload_file
|
| 193 |
-
|
| 194 |
-
# Save the model card
|
| 195 |
-
model_card = """<paste the content above>"""
|
| 196 |
-
|
| 197 |
-
with open("README.md", "w") as f:
|
| 198 |
-
f.write(model_card)
|
| 199 |
-
|
| 200 |
-
upload_file(
|
| 201 |
-
path_or_fileobj="README.md",
|
| 202 |
-
path_in_repo="README.md",
|
| 203 |
-
repo_id="alexanderquispe/naics-github-classifier",
|
| 204 |
-
repo_type="model"
|
| 205 |
-
)
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
library_name: transformers
|
| 6 |
+
tags:
|
| 7 |
+
- text-classification
|
| 8 |
+
- naics
|
| 9 |
+
- industry-classification
|
| 10 |
+
- github
|
| 11 |
+
- roberta
|
| 12 |
+
datasets:
|
| 13 |
+
- custom
|
| 14 |
+
metrics:
|
| 15 |
+
- f1
|
| 16 |
+
- accuracy
|
| 17 |
+
pipeline_tag: text-classification
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
# NAICS GitHub Repository Classifier
|
| 21 |
+
|
| 22 |
+
A fine-tuned RoBERTa-large model that classifies GitHub repositories into **19 NAICS (North American Industry Classification System)** industry sectors based on repository metadata.
|
| 23 |
+
|
| 24 |
+
## Model Description
|
| 25 |
+
|
| 26 |
+
This model takes GitHub repository information (name, description, topics, README) and predicts the most likely industry sector the repository belongs to.
|
| 27 |
+
|
| 28 |
+
- **Model:** `roberta-large` (355M parameters)
|
| 29 |
+
- **Task:** Multi-class text classification (19 classes)
|
| 30 |
+
- **Language:** English
|
| 31 |
+
- **Training Data:** 6,588 labeled GitHub repositories
|
| 32 |
+
|
| 33 |
+
## Intended Use
|
| 34 |
+
|
| 35 |
+
- Classifying GitHub repositories by industry sector
|
| 36 |
+
- Analyzing open-source software ecosystem by industry
|
| 37 |
+
- Research on technology adoption across industries
|
| 38 |
+
|
| 39 |
+
## NAICS Classes
|
| 40 |
+
|
| 41 |
+
| Label | NAICS Code | Industry Sector |
|
| 42 |
+
|-------|------------|-----------------|
|
| 43 |
+
| 0 | 11 | Agriculture, Forestry, Fishing and Hunting |
|
| 44 |
+
| 1 | 21 | Mining, Quarrying, Oil and Gas Extraction |
|
| 45 |
+
| 2 | 22 | Utilities |
|
| 46 |
+
| 3 | 23 | Construction |
|
| 47 |
+
| 4 | 31-33 | Manufacturing |
|
| 48 |
+
| 5 | 42 | Wholesale Trade |
|
| 49 |
+
| 6 | 44-45 | Retail Trade |
|
| 50 |
+
| 7 | 48-49 | Transportation and Warehousing |
|
| 51 |
+
| 8 | 51 | Information |
|
| 52 |
+
| 9 | 52 | Finance and Insurance |
|
| 53 |
+
| 10 | 53 | Real Estate and Rental |
|
| 54 |
+
| 11 | 54 | Professional, Scientific, Technical Services |
|
| 55 |
+
| 12 | 56 | Administrative and Support Services |
|
| 56 |
+
| 13 | 61 | Educational Services |
|
| 57 |
+
| 14 | 62 | Health Care and Social Assistance |
|
| 58 |
+
| 15 | 71 | Arts, Entertainment, and Recreation |
|
| 59 |
+
| 16 | 72 | Accommodation and Food Services |
|
| 60 |
+
| 17 | 81 | Other Services |
|
| 61 |
+
| 18 | 92 | Public Administration |
|
| 62 |
+
|
| 63 |
+
## Usage
|
| 64 |
+
|
| 65 |
+
### Quick Start
|
| 66 |
+
|
| 67 |
+
```python
|
| 68 |
+
from transformers import pipeline
|
| 69 |
+
|
| 70 |
+
classifier = pipeline(
|
| 71 |
+
"text-classification",
|
| 72 |
+
model="alexanderquispe/naics-github-classifier"
|
| 73 |
+
)
|
| 74 |
+
|
| 75 |
+
text = "Repository: bank-api | Description: REST API for banking transactions | README: A secure API for financial operations"
|
| 76 |
+
result = classifier(text)
|
| 77 |
+
print(result)
|
| 78 |
+
# [{'label': '52', 'score': 0.95}] # Finance and Insurance
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
### Full Example
|
| 82 |
+
|
| 83 |
+
```python
|
| 84 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
| 85 |
+
import torch
|
| 86 |
+
|
| 87 |
+
model = AutoModelForSequenceClassification.from_pretrained("alexanderquispe/naics-github-classifier")
|
| 88 |
+
tokenizer = AutoTokenizer.from_pretrained("alexanderquispe/naics-github-classifier")
|
| 89 |
+
|
| 90 |
+
# Format input
|
| 91 |
+
text = "Repository: mediscan | Description: AI diagnostic tool for radiology | Topics: healthcare; medical-imaging; deep-learning | README: MediScan uses computer vision to assist radiologists..."
|
| 92 |
+
|
| 93 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
|
| 94 |
+
outputs = model(**inputs)
|
| 95 |
+
predicted_class = torch.argmax(outputs.logits, dim=1).item()
|
| 96 |
+
|
| 97 |
+
# Map to NAICS code
|
| 98 |
+
id2label = model.config.id2label
|
| 99 |
+
print(f"Predicted NAICS: {id2label[predicted_class]}") # 62 (Health Care)
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
## Input Format
|
| 103 |
+
|
| 104 |
+
The model expects text in this format:
|
| 105 |
+
|
| 106 |
+
```
|
| 107 |
+
Repository: {repo_name} | Description: {description} | Topics: {topics} | README: {readme_content}
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
| Field | Required | Description |
|
| 111 |
+
|-------|----------|-------------|
|
| 112 |
+
| Repository | Yes | Repository name |
|
| 113 |
+
| Description | No | Short description |
|
| 114 |
+
| Topics | No | Semicolon-separated tags |
|
| 115 |
+
| README | No | README content (can be truncated) |
|
| 116 |
+
|
| 117 |
+
## Training Details
|
| 118 |
+
|
| 119 |
+
### Training Data
|
| 120 |
+
|
| 121 |
+
- **Source:** GitHub repositories labeled with NAICS codes
|
| 122 |
+
- **Size:** 6,588 examples
|
| 123 |
+
- **Classes:** 19 NAICS sectors
|
| 124 |
+
- **Split:** 70% train / 10% validation / 20% test
|
| 125 |
+
|
| 126 |
+
### Training Hyperparameters
|
| 127 |
+
|
| 128 |
+
| Parameter | Value |
|
| 129 |
+
|-----------|-------|
|
| 130 |
+
| Base Model | `roberta-large` |
|
| 131 |
+
| Batch Size | 32 |
|
| 132 |
+
| Learning Rate | 2e-5 |
|
| 133 |
+
| Epochs | 8 |
|
| 134 |
+
| Max Sequence Length | 512 |
|
| 135 |
+
| Optimizer | AdamW |
|
| 136 |
+
| Weight Decay | 0.01 |
|
| 137 |
+
| Early Stopping Patience | 5 |
|
| 138 |
+
|
| 139 |
+
### Preprocessing
|
| 140 |
+
|
| 141 |
+
Text preprocessing includes:
|
| 142 |
+
- Removal of markdown badges and formatting
|
| 143 |
+
- URL cleaning (keep domain names)
|
| 144 |
+
- License header removal
|
| 145 |
+
- Code block removal (keep language indicators)
|
| 146 |
+
- Technology term normalization (js → javascript, py → python)
|
| 147 |
+
- Whitespace normalization
|
| 148 |
+
|
| 149 |
+
## Limitations
|
| 150 |
+
|
| 151 |
+
- Trained primarily on English repositories
|
| 152 |
+
- May not generalize to non-software repositories
|
| 153 |
+
- NAICS code 55 (Management of Companies) excluded due to limited training data
|
| 154 |
+
- Performance may vary for repositories with minimal README content
|
| 155 |
+
|
| 156 |
+
## Citation
|
| 157 |
+
|
| 158 |
+
```bibtex
|
| 159 |
+
@misc{naics-github-classifier,
|
| 160 |
+
author = {Alexander Quispe},
|
| 161 |
+
title = {NAICS GitHub Repository Classifier},
|
| 162 |
+
year = {2025},
|
| 163 |
+
publisher = {Hugging Face},
|
| 164 |
+
url = {https://huggingface.co/alexanderquispe/naics-github-classifier}
|
| 165 |
+
}
|
| 166 |
+
```
|
| 167 |
+
|
| 168 |
+
## Repository
|
| 169 |
+
|
| 170 |
+
Training code and data preparation: [github.com/alexanderquispe/naics-github-train](https://github.com/alexanderquispe/naics-github-train)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|