Downloads · 30 days
14
47% of all-time downloads
jainjohn/logistics-event-classifier
logistics-event-classifier is a machine learning model from jainjohn. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
modelcardcontent = """ --- language: en license: apache-2.0 tags: - logistics - text-classification - supply-chain - operations - business-intelligence datasets: - custom-logistics-events metrics: - accuracy - f1 - pr…
Downloads · 30 days
14
47% of all-time downloads
All-time downloads
30
Public
Parameters
67M
268 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors268 MB · 100%
From the Hugging Face model README
language: en license: apache-2.0 tags:
This model is a fine-tuned transformer-based classifier designed specifically for categorizing operational events in business and logistics platforms. It automatically classifies text descriptions of logistics events into 8 distinct categories, enabling real-time intelligence and automated workflow management.
Primary Use Cases:
Intended Users:
The model classifies events into 8 categories:
| Category | Description | Example |
|---|---|---|
order_event | Order creation, confirmation, cancellation | "Order #12345 created successfully" |
delivery | Shipping, transit, delivery status | "Shipment delayed due to weather" |
vendor_issue | Supplier problems, quality issues | "Vendor failed to deliver materials" |
inventory | Stock levels, warehouse capacity | "Low stock alert for SKU-9876" |
invoice | Payment, billing, invoicing | "Invoice #789 approved for payment" |
critical_issue | Urgent problems requiring immediate attention | "URGENT: Container stuck at customs" |
customer_service | Customer complaints, returns, support | "Customer complaint about damaged goods" |
operations | Fleet, maintenance, route optimization | "Route optimization completed" |
The training data is balanced across categories with the following distribution:
{class_distribution}
Model: {base_model}
Epochs: {num_epochs}
Batch Size: {batch_size}
Learning Rate: {learning_rate}
Weight Decay: {weight_decay}
Warmup Steps: {warmup_steps}
Optimizer: AdamW
Mixed Precision: {fp16}
Max Sequence Length: 128
The model was fine-tuned using the Hugging Face Trainer API with:
Overall Performance:
Accuracy: {accuracy:.4f}
Precision: {precision:.4f}
Recall: {recall:.4f}
F1-Score: {f1:.4f}
{per_category_metrics}
The confusion matrix shows the model's prediction accuracy across all categories:
{confusion_matrix_summary}
pip install transformers torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load model and tokenizer
model_name = "your-username/logistics-event-classifier"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
# Prepare input
text = "Shipment delayed due to weather conditions"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
# Get prediction
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
predicted_class = torch.argmax(predictions, dim=-1).item()
# Category mapping
categories = {
0: "order_event", 1: "delivery", 2: "vendor_issue",
3: "inventory", 4: "invoice", 5: "critical_issue",
6: "customer_service", 7: "operations"
}
print(f"Predicted Category: {categories[predicted_class]}")
print(f"Confidence: {predictions[0][predicted_class]:.2%}")
from transformers import pipeline
# Create classifier pipeline
classifier = pipeline(
"text-classification",
model="your-username/logistics-event-classifier"
)
# Classify single event
result = classifier("Invoice #12345 approved for payment")
print(result)
# Batch classification
events = [
"Order cancelled by customer",
"Low stock alert for critical component",
"Delivery completed on time"
]
results = classifier(events)
print(results)
from fastapi import FastAPI
from transformers import pipeline
app = FastAPI()
classifier = pipeline("text-classification", model="your-username/logistics-event-classifier")
@app.post("/classify")
async def classify_event(text: str):
result = classifier(text)[0]
return {
"text": text,
"category": result['label'],
"confidence": result['score']
}
❌ NOT suitable for:
| Version | Date | Changes |
|---|---|---|
| 1.0.0 | {release_date} | Initial release with 8 categories |
Recommended retraining frequency: Quarterly or when:
Key metrics to monitor in production:
If you use this model in your research or production systems, please cite:
@misc{logistics-event-classifier-2025,
author = {Your Name},
title = {Logistics Event Classifier: Automated Classification for Supply Chain Intelligence},
year = {2025},
publisher = {Hugging Face},
howpublished = {\\url{https://huggingface.co/your-username/logistics-event-classifier}}
}
This model is released under the Apache 2.0 License. See LICENSE file for details.
Disclaimer: This model is provided "as-is" without warranties. Users are responsible for testing and validation in their specific use cases. Always implement proper monitoring, fallback mechanisms, and human oversight in production systems. """
model_card_filled = model_card_content.format( base_model=MODEL_NAME, num_params=model.num_parameters(), train_date=datetime.now().strftime("%Y-%m-%d"), total_samples=len(df), train_samples=len(train_data), test_samples=len(test_data), avg_length=int(df['text'].str.len().mean()), max_length=128, class_distribution=df['label_name'].value_counts().to_string(), tokenizer_name=MODEL_NAME, num_epochs=training_args.num_train_epochs, batch_size=training_args.per_device_train_batch_size, learning_rate=training_args.learning_rate, weight_decay=training_args.weight_decay, warmup_steps=training_args.warmup_steps, fp16="Yes" if training_args.fp16 else "No", hardware="Google Colab", gpu_name=torch.cuda.get_device_name(0) if torch.cuda.is_available() else "CPU", training_time=train_result.metrics['train_runtime'], samples_per_sec=train_result.metrics['train_samples_per_second'], accuracy=eval_results['eval_accuracy'], precision=eval_results['eval_precision'], recall=eval_results['eval_recall'], f1=eval_results['eval_f1'], per_category_metrics=classification_report(true_labels, predictions, target_names=target_names, digits=4), confusion_matrix_summary=f"See visualization above for detailed confusion matrix", release_date=datetime.now().strftime("%Y-%m-%d") )
model_card_path = f"{save_directory}/README.md" with open(model_card_path, 'w', encoding='utf-8') as f: f.write(model_card_filled)
print("="*70) print("📄 MODEL CARD CREATED") print("="*70) print(f"✅ Model card saved to: {model_card_path}") print(f"✅ Length: {len(model_card_filled)} characters") print("\nModel card includes:") print(" • Comprehensive model description") print(" • Training details and hyperparameters") print(" • Performance metrics and benchmarks") print(" • Usage examples (Python, API)") print(" • Bias and ethical considerations") print(" • Maintenance recommendations") print(" • Citation information") print("="*70)
print("\n📋 MODEL CARD PREVIEW (First 1000 characters):\n") print(model_card_filled[:1000] + "...\n")