Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
base_model:
|
| 6 |
+
- sentence-transformers/all-MiniLM-L6-v2
|
| 7 |
+
datasets:
|
| 8 |
+
- itsjhuang/watsonx-docs-document-type
|
| 9 |
+
tags:
|
| 10 |
+
- text-classification
|
| 11 |
+
- embeddings
|
| 12 |
+
- technical-documentation
|
| 13 |
+
metrics:
|
| 14 |
+
- accuracy
|
| 15 |
+
- f1
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# Watsonx Docs Document Type Classifier
|
| 19 |
+
|
| 20 |
+
Binary classifier for IBM Watsonx technical documentation pages.
|
| 21 |
+
Given a documentation page, the model predicts whether it is:
|
| 22 |
+
|
| 23 |
+
- `conceptual` (0): primarily used to understand or look up information
|
| 24 |
+
- `how-to` (1): primarily used to complete a procedure or fix a problem
|
| 25 |
+
|
| 26 |
+
## Model Details
|
| 27 |
+
|
| 28 |
+
| | |
|
| 29 |
+
|---|---|
|
| 30 |
+
| Base embeddings | sentence-transformers/all-MiniLM-L6-v2 |
|
| 31 |
+
| Classifier | LinearSVC (C=1.0, max_iter=2000) |
|
| 32 |
+
| Training dataset | [itsjhuang/watsonx-docs-document-type](https://huggingface.co/datasets/itsjhuang/watsonx-docs-document-type) |
|
| 33 |
+
| Input | title + first 800 words of document |
|
| 34 |
+
| Output | `conceptual` or `how-to` |
|
| 35 |
+
|
| 36 |
+
## Evaluation Results
|
| 37 |
+
|
| 38 |
+
Three conditions were trained and evaluated. The best model (B) was selected by test macro F1.
|
| 39 |
+
|
| 40 |
+
| Condition | Embedding Model | Classifier | Train Acc | Train F1 | Test Acc | Test F1 |
|
| 41 |
+
|---|---|---|---:|---:|---:|---:|
|
| 42 |
+
| A | all-MiniLM-L6-v2 | Logistic Regression | 0.879 | 0.879 | 0.817 | 0.817 |
|
| 43 |
+
| B ✅ | all-MiniLM-L6-v2 | LinearSVC | 0.971 | 0.971 | 0.867 | 0.867 |
|
| 44 |
+
| C | bge-small-en-v1.5 | Logistic Regression | 0.864 | 0.864 | 0.833 | 0.833 |
|
| 45 |
+
|
| 46 |
+
Confusion matrices for each condition are available in the repository files.
|
| 47 |
+
|
| 48 |
+
## Usage
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
```python
|
| 52 |
+
import joblib
|
| 53 |
+
import numpy as np
|
| 54 |
+
from sentence_transformers import SentenceTransformer
|
| 55 |
+
|
| 56 |
+
embedder = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
|
| 57 |
+
clf = joblib.load("best_model.joblib")
|
| 58 |
+
|
| 59 |
+
def softmax(x):
|
| 60 |
+
e = np.exp(x - np.max(x))
|
| 61 |
+
return e / e.sum()
|
| 62 |
+
|
| 63 |
+
def predict(text):
|
| 64 |
+
embedding = embedder.encode([text], convert_to_numpy=True)
|
| 65 |
+
scores = clf.decision_function(embedding)[0]
|
| 66 |
+
if np.ndim(scores) == 0:
|
| 67 |
+
scores = np.array([-scores, scores])
|
| 68 |
+
probs = softmax(scores)
|
| 69 |
+
labels = ["conceptual", "how-to"]
|
| 70 |
+
return dict(zip(labels, probs))
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
## Limitations
|
| 75 |
+
|
| 76 |
+
- Trained on IBM Watsonx documentation only; may not generalize to other
|
| 77 |
+
technical documentation domains.
|
| 78 |
+
- Label boundary between weak procedural pages and conceptual capability
|
| 79 |
+
descriptions remains a residual source of error.
|
| 80 |
+
|
| 81 |
+
## Source Dataset
|
| 82 |
+
|
| 83 |
+
Derived from
|
| 84 |
+
[`ibm-research/watsonxDocsQA`](https://huggingface.co/datasets/ibm-research/watsonxDocsQA),
|
| 85 |
+
licensed under Apache 2.0.
|