spaCy
English
b2b_ecommerce_ner
named-entity-recognition
b2b
ecommerce
order-processing
product-extraction
Eval Results (legacy)
Instructions to use Purva17/b2b-ecomm-ner with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- spaCy
How to use Purva17/b2b-ecomm-ner with spaCy:
!pip install https://huggingface.co/Purva17/b2b-ecomm-ner/resolve/main/b2b-ecomm-ner-any-py3-none-any.whl # Using spacy.load(). import spacy nlp = spacy.load("b2b-ecomm-ner") # Importing as module. import b2b-ecomm-ner nlp = b2b-ecomm-ner.load() - Notebooks
- Google Colab
- Kaggle
| """ | |
| Example usage of the B2B Ecommerce NER model for Hugging Face | |
| """ | |
| import sys | |
| import os | |
| sys.path.append(os.path.dirname(__file__)) | |
| from model import B2BEcommerceNER | |
| def main(): | |
| """Demonstrate the B2B Ecommerce NER model usage""" | |
| print("B2B Ecommerce NER Model - Example Usage") | |
| print("=" * 50) | |
| # Sample B2B order texts | |
| sample_orders = [ | |
| "Order 5 bottles of Coca Cola 650ML", | |
| "I need 10 packs of Maggi noodles 200G each", | |
| "Send 3 units of Chocolate Cleanser 500ML", | |
| "Please deliver 15 pieces of Golden Dates 250G", | |
| "We want 8 cases of mineral water 1L bottles" | |
| ] | |
| try: | |
| # Initialize the model (without loading since we don't have the actual model files yet) | |
| print("Initializing B2B Ecommerce NER model...") | |
| model = B2BEcommerceNER() | |
| print("Model configuration:") | |
| print(f"- Entity labels: {model.entity_labels}") | |
| print(f"- Model path: {model.model_path}") | |
| print(f"- Catalog path: {model.catalog_path}") | |
| print("\nSample order processing would work like this:") | |
| print("-" * 40) | |
| for i, order in enumerate(sample_orders, 1): | |
| print(f"\n{i}. Order: '{order}'") | |
| print(" Expected entities:") | |
| # Manually show expected results (since model isn't loaded) | |
| if "5 bottles of Coca Cola 650ML" in order: | |
| print(" - QUANTITY: '5'") | |
| print(" - UNIT: 'bottles'") | |
| print(" - PRODUCT: 'Coca Cola'") | |
| print(" - SIZE: '650ML'") | |
| elif "10 packs of Maggi" in order: | |
| print(" - QUANTITY: '10'") | |
| print(" - UNIT: 'packs'") | |
| print(" - PRODUCT: 'Maggi noodles'") | |
| print(" - SIZE: '200G'") | |
| elif "3 units of Chocolate Cleanser" in order: | |
| print(" - QUANTITY: '3'") | |
| print(" - UNIT: 'units'") | |
| print(" - PRODUCT: 'Chocolate Cleanser'") | |
| print(" - SIZE: '500ML'") | |
| elif "15 pieces of Golden Dates" in order: | |
| print(" - QUANTITY: '15'") | |
| print(" - UNIT: 'pieces'") | |
| print(" - PRODUCT: 'Golden Dates'") | |
| print(" - SIZE: '250G'") | |
| elif "8 cases of mineral water" in order: | |
| print(" - QUANTITY: '8'") | |
| print(" - UNIT: 'cases'") | |
| print(" - PRODUCT: 'mineral water'") | |
| print(" - SIZE: '1L'") | |
| print("\n" + "=" * 50) | |
| print("To use with actual trained model:") | |
| print("1. Train your model using the main training pipeline") | |
| print("2. Copy the trained spaCy model to huggingface_model/spacy_model/") | |
| print("3. Copy product_catalog.csv to huggingface_model/") | |
| print("4. Use model.predict(texts) for actual entity extraction") | |
| print("\nCode example:") | |
| print(""" | |
| # Load pre-trained model | |
| model = B2BEcommerceNER.from_pretrained('path/to/saved/model') | |
| # Extract entities | |
| results = model.predict(['Order 5 Coke Zero 650ML']) | |
| # Access entities | |
| entities = results[0]['entities'] | |
| products = entities['products'] | |
| quantities = entities['quantities'] | |
| catalog_matches = entities['catalog_matches'] | |
| """) | |
| except Exception as e: | |
| print(f"Note: {e}") | |
| print("This is expected since the actual model files are not loaded yet.") | |
| if __name__ == "__main__": | |
| main() | |