Vu Anh
Claude
commited on
Commit
·
76a11b5
1
Parent(s):
0b1c1cf
Update use_this_model.py with latest SVC model and verify Hub availability
Browse files- Updated model filename to uts2017_sentiment_20250928_131716.joblib
- Added error handling for model download verification
- Added model type information (SVC) in output
- Updated performance metrics (71.72% accuracy)
- Verified model is successfully published and accessible on Hugging Face Hub
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
- use_this_model.py +19 -10
use_this_model.py
CHANGED
|
@@ -33,16 +33,23 @@ def predict_text(model, text):
|
|
| 33 |
|
| 34 |
def load_model_from_hub():
|
| 35 |
"""Load the pre-trained Pulse Core 1 banking aspect sentiment model from Hugging Face Hub"""
|
| 36 |
-
filename = "
|
| 37 |
print("Downloading Pulse Core 1 (Vietnamese Banking Aspect Sentiment) model from Hugging Face Hub...")
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
|
| 48 |
def predict_banking_examples(model):
|
|
@@ -144,7 +151,7 @@ import joblib
|
|
| 144 |
|
| 145 |
# Download and load Pulse Core 1 model from HuggingFace Hub
|
| 146 |
model = joblib.load(
|
| 147 |
-
hf_hub_download("undertheseanlp/pulse_core_1", "
|
| 148 |
)
|
| 149 |
|
| 150 |
# Make prediction on banking text
|
|
@@ -197,9 +204,11 @@ def main():
|
|
| 197 |
print("\nDemonstration complete!")
|
| 198 |
print("\nPulse Core 1 model is available on Hugging Face Hub:")
|
| 199 |
print("- Repository: undertheseanlp/pulse_core_1")
|
| 200 |
-
print("- Model file:
|
| 201 |
print("- Task: Vietnamese Banking Aspect Sentiment Analysis")
|
| 202 |
print("- Classes: 35 aspect-sentiment combinations")
|
|
|
|
|
|
|
| 203 |
|
| 204 |
except ImportError:
|
| 205 |
print("Error: huggingface_hub is required. Install with:")
|
|
|
|
| 33 |
|
| 34 |
def load_model_from_hub():
|
| 35 |
"""Load the pre-trained Pulse Core 1 banking aspect sentiment model from Hugging Face Hub"""
|
| 36 |
+
filename = "uts2017_sentiment_20250928_131716.joblib"
|
| 37 |
print("Downloading Pulse Core 1 (Vietnamese Banking Aspect Sentiment) model from Hugging Face Hub...")
|
| 38 |
|
| 39 |
+
try:
|
| 40 |
+
model_path = hf_hub_download("undertheseanlp/pulse_core_1", filename)
|
| 41 |
+
print(f"Model downloaded to: {model_path}")
|
| 42 |
+
|
| 43 |
+
print("Loading model...")
|
| 44 |
+
model = joblib.load(model_path)
|
| 45 |
+
print(f"Model loaded successfully. Classes: {len(model.classes_)} aspect-sentiment combinations")
|
| 46 |
+
print(f"Model type: {type(model.named_steps['clf']).__name__}")
|
| 47 |
+
return model
|
| 48 |
+
except Exception as e:
|
| 49 |
+
print(f"Error downloading model: {e}")
|
| 50 |
+
print("This might mean the model file hasn't been uploaded to Hugging Face Hub yet.")
|
| 51 |
+
print("Please check the repository: https://huggingface.co/undertheseanlp/pulse_core_1")
|
| 52 |
+
raise
|
| 53 |
|
| 54 |
|
| 55 |
def predict_banking_examples(model):
|
|
|
|
| 151 |
|
| 152 |
# Download and load Pulse Core 1 model from HuggingFace Hub
|
| 153 |
model = joblib.load(
|
| 154 |
+
hf_hub_download("undertheseanlp/pulse_core_1", "uts2017_sentiment_20250928_131716.joblib")
|
| 155 |
)
|
| 156 |
|
| 157 |
# Make prediction on banking text
|
|
|
|
| 204 |
print("\nDemonstration complete!")
|
| 205 |
print("\nPulse Core 1 model is available on Hugging Face Hub:")
|
| 206 |
print("- Repository: undertheseanlp/pulse_core_1")
|
| 207 |
+
print("- Model file: uts2017_sentiment_20250928_131716.joblib")
|
| 208 |
print("- Task: Vietnamese Banking Aspect Sentiment Analysis")
|
| 209 |
print("- Classes: 35 aspect-sentiment combinations")
|
| 210 |
+
print("- Model type: Support Vector Classification (SVC)")
|
| 211 |
+
print("- Test accuracy: 71.72%")
|
| 212 |
|
| 213 |
except ImportError:
|
| 214 |
print("Error: huggingface_hub is required. Install with:")
|