Token Classification
Transformers
Safetensors
Arabic
bert
hadith
sanad
matn
hadith-separator
hadith_separator
islam
hadithBERT
Instructions to use SHK4K/hadith-segmentation-bert with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use SHK4K/hadith-segmentation-bert with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="SHK4K/hadith-segmentation-bert")# Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("SHK4K/hadith-segmentation-bert") model = AutoModelForTokenClassification.from_pretrained("SHK4K/hadith-segmentation-bert") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -80,13 +80,13 @@ for token, pred_id in zip(input_tokens, predictions):
|
|
| 80 |
label = id2label.get(pred_id, "O")
|
| 81 |
|
| 82 |
if "SANAD" in label:
|
| 83 |
-
|
| 84 |
elif "MATN" in label:
|
| 85 |
-
|
| 86 |
|
| 87 |
# Reconstruct clean component strings
|
| 88 |
-
final_sanad = tokenizer.convert_tokens_to_string(
|
| 89 |
-
final_matn = tokenizer.convert_tokens_to_string(
|
| 90 |
|
| 91 |
print("--- Extracted Components ---")
|
| 92 |
print(f"SANAD: {final_sanad.strip()}\n")
|
|
|
|
| 80 |
label = id2label.get(pred_id, "O")
|
| 81 |
|
| 82 |
if "SANAD" in label:
|
| 83 |
+
sanad_tokens.append(token)
|
| 84 |
elif "MATN" in label:
|
| 85 |
+
matn_tokens.append(token)
|
| 86 |
|
| 87 |
# Reconstruct clean component strings
|
| 88 |
+
final_sanad = tokenizer.convert_tokens_to_string(sanad_tokens)
|
| 89 |
+
final_matn = tokenizer.convert_tokens_to_string(matn_tokens)
|
| 90 |
|
| 91 |
print("--- Extracted Components ---")
|
| 92 |
print(f"SANAD: {final_sanad.strip()}\n")
|