Views
No views yet
overall_score: 0.990 Spearman correlationglobal_top_1m_share: 0.993 Spearman correlationscore_food: 0.973 Spearman correlationthree_letter_registration_percent: 0.969 Spearman correlationgoogle/bert_uncased_L-4_H-256_A-4 (Lightweight BERT)tld_research_data.jsonl)tld_technical_data.jsonl)country_economic_data.jsonl)tld_price_scores_by_industry_2025.csv)compute_tld_scores_pairwise.py)1from transformers import AutoTokenizer, AutoModel
2import torch
3
4# Load model and tokenizer
5model_name = "humbleworth/tld-embedding"
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModel.from_pretrained(model_name)
8model.eval()1def get_tld_embedding(tld, model, tokenizer):
2 """Get 96-dimensional embedding for a single TLD"""
3 # Use special token format if available, otherwise prefix with dot
4 tld_text = f"[TLD_{tld}]" if f"[TLD_{tld}]" in tokenizer.vocab else f".{tld}"
5
6 inputs = tokenizer(
7 tld_text,
8 return_tensors="pt",
9 padding="max_length",
10 truncation=True,
11 max_length=8
12 )
13
14 with torch.no_grad():
15 outputs = model.encoder(**inputs)
16 cls_embedding = outputs.last_hidden_state[:, 0, :]
17 tld_embedding = model.projection(cls_embedding)
18
19 return tld_embedding.squeeze().numpy()
20
21# Example
22com_embedding = get_tld_embedding("com", model, tokenizer)
23print(f"Embedding shape: {com_embedding.shape}") # (96,)1def get_tld_embeddings_batch(tlds, model, tokenizer):
2 """Get embeddings for multiple TLDs efficiently"""
3 # Use special token format if available, otherwise prefix with dot
4 tld_texts = [f"[TLD_{tld}]" if f"[TLD_{tld}]" in tokenizer.vocab else f".{tld}" for tld in tlds]
5
6 inputs = tokenizer(
7 tld_texts,
8 return_tensors="pt",
9 padding="max_length",
10 truncation=True,
11 max_length=8
12 )
13
14 with torch.no_grad():
15 outputs = model.encoder(**inputs)
16 cls_embeddings = outputs.last_hidden_state[:, 0, :]
17 tld_embeddings = model.projection(cls_embeddings)
18
19 return tld_embeddings.numpy()
20
21# Process multiple TLDs
22tlds = ["com", "io", "ai", "co.za", "tech"]
23embeddings = get_tld_embeddings_batch(tlds, model, tokenizer)
24print(f"Embeddings shape: {embeddings.shape}") # (5, 96)1python train_dual_task_embeddings.py \
2 --epochs 25 \
3 --batch-size 16 \
4 --learning-rate 5e-4 \
5 --warmup-steps 200 \
6 --output-dir models/tld_embedding_modeltld_embedding_model/
├── config.json # Model configuration
├── pytorch_model.bin # Model weights
├── tokenizer.json # Tokenizer
├── tokenizer_config.json # Tokenizer config
├── vocab.txt # Vocabulary
├── special_tokens_map.json # Special tokens
├── training_metrics.pt # Training metrics
├── tld_embeddings.json # Pre-computed embeddings
└── README.md # This file1@software{tld_embedding_2025,
2 title = {TLD Embedding Model: Multi-Task Learning for Domain Extensions},
3 author = {HumbleWorth},
4 year = {2025},
5 note = {Achieved 0.8976 average Spearman correlation across 63 features},
6 url = {https://huggingface.co/humbleworth/tld-embedding}
7}