Knowledge2Model/Hugging2KG
Hitesh Karakoti b6a1e6cc46 Updated Workflow 2025-10-08 01:14:06 +02:00
..
Readme.md Updated Workflow 2025-10-08 01:14:06 +02:00
extract_model_cards.py enabled hf transfer 2025-09-02 11:02:33 +02:00
filterInvalidTags.py Improve tag filtering 2025-10-08 00:31:19 +02:00
hugging2sql.py Updated model parameter 2025-08-27 16:06:47 +02:00
huggingface2.db ModelcardTags + Metrices Only, No HealthStatus 2025-10-08 00:40:18 +02:00
metric_mapping.json Added Graph Query by Modality + streamlined metrics 2025-02-18 22:22:56 +01:00
modality_mapping.json addad modalitys to graph creation+ 2025-02-18 15:21:59 +01:00
model_card_tag_extractor.py better prompt 2025-09-02 11:04:18 +02:00
model_tags_extract_multi.py multithreading + batch updates for faster tag extraction 2025-09-02 11:14:45 +02:00

Readme.md

Hugging2KG Pipeline (Updated)

Purpose

Crawl HuggingFace API, extract model metadata using LLM, and prepare data for Knowledge Graph construction.


Pipeline Flow

Stage 1: Data Collection

  1. hugging2sql.py - API Crawler
    • Crawls HuggingFace API for ML models
    • Stores raw model data in SQLite database
    • Output: huggingface2.db

Stage 2: Model Card Extraction

  1. extract_model_cards.py - README Fetcher
    • Fetches README.md (model cards) from HuggingFace for each model
    • Stores complete model cards in database
    • Updates: huggingface2.db (adds model_card column)

Stage 3: LLM-Based Tag Extraction

  1. model_card_tag_extractor.py - Intelligent Tag Extraction
    • Uses LLM (via LM Studio) to extract structured technical tags from model cards
    • Generates both model_card_tags and metrics separately
    • Updates: huggingface2.db (adds model_card_tags and metrics columns)

Stage 4: Tag Cleaning & Validation

  1. filterInvalidTags.py - Tag Quality Control
    • Cleans and validates LLM-extracted tags
    • Updates: huggingface2.db (cleans model_card_tags and metrics)

Supporting Files (Currently Used)

  • metric_mapping.json - Normalizes metric names across different formats
    • Example: "acc", "accuracy", "acc/f1" → "Accuracy"
    • Used by downstream scripts for metric standardization

Supporting Files (Not Currently Used)

  • modality_mapping.json - Maps problem types to input/output modalities (legacy)

Workflow Summary

Complete pipeline (run in order):

1. python hugging2sql.py                  # Crawl HuggingFace API → creates DB
2. python extract_model_cards.py          # Fetch model cards → adds model_card column
3. python model_card_tag_extractor.py     # LLM extracts tags → adds model_card_tags & metrics
4. python filterInvalidTags.py            # Clean/validate tags → final cleanup